PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » File Formats » Spreadsheet_Excel_Writer » Bug #1521

insertBitmap makes the XLS file invalid

Details

Submitted2004-05-28 09:36 UTC
Fromlelio at ssitalia dot com
Assignedxnoguer
StatusClosed
PackageSpreadsheet_Excel_Writer
PHP Version4.3.6
OSLinux
Roadmaps(Not assigned)

Comments

[2004-05-28 09:36 UTC] lelio at ssitalia dot com

Description:
------------
Inserting any kind (or resolution) of BMP image makes the XLS file invalid and unreadable by Excel 2003. I've tried even on Excel XP.

Reproduce code:
---------------
$workbook = new Spreadsheet_Excel_Writer() ;
$workbook->send('report.xls') ;
$worksheet =& $workbook->addWorksheet('Report') ;
$worksheet->insertBitmap(0,0,'report.bmp') ;
$workbook->close() ;

Expected result:
----------------
To get Excel load the file without troubles.

Actual result:
--------------
If the image is great enough (120x120), Excel first shows a dialog it has not enough resources, then a second one where it says the file is damaged. If the image is smaller (10x10), it just skips to the second one.

[2004-06-15 10:48 UTC] alexbarnes at hotmail dot com

I have also had this problem but I have managed to code a workaround. Sorry I dont have a CVS account and since I haven't tested this thoroughly I wouldn't like to submit this as an official change yet.

*****THIS IS NOT TESTED ON WINDOWS******
but I see no reason why it wouldn't work on any platform.

Code Fix:

Worksheet.php - Line: 3370

Change from:
if ($identity[''] != "BM") {

To:
if ($identity[1] != "BM") {

Worksheet.php - Line: 3381

Change from:
$size = $size_array[''];

To:
$size = $size_array[1];

It seems that the associative array is not formatted the same for both Windows and Linux, I'm no PHP expert so I don't know why this is a problem but hey if it works I am happy.

I hope this helps someone!

[2004-06-15 13:15 UTC] xnoguer at php dot net

This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pear.php.net.

In case this was a pear.php.net website problem, the change will show
up on the website in short time.

Thank you for the report, and for helping us make PEAR better.