Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.9.4

Bug #2862 insertBitmap scales image incorrect in Excel 2000
Submitted: 2004-12-01 09:41 UTC
From: thomas dot keller at inatec dot com Assigned:
Status: Verified Package: Spreadsheet_Excel_Writer
PHP Version: 4.3.4 OS: RH9
Roadmaps: (Not assigned)    
Subscription  


 [2004-12-01 09:41 UTC] thomas dot keller at inatec dot com
Description: ------------ In Excel 2000 a bitmap is always scaled incorrectly if it is inserted via insertBitmap (and no scale/ position attributes), regardless where I put the image. The author of _positionImage in Worksheet.php notes that "the SDK incorrectly states that the height should be expressed as a percentage of 1024." thus uses for the height a value of only 256. I changed these values to 1024 which made the insert work correctly for me. Reproduce code: --------------- $file = "/path/to/file/bitmap.bmp"; $worksheet->insertBitmap(0, 0, $file);

Comments

 [2006-03-01 12:31 UTC] roh at m3 dot net (Rob Hunter)
The scaling is visibly off in Excel 2003, as well, but I didn't have much luck using a factor of 1024 instead of 256. If my calling code uses a scale of (1, 0.8) to mean (1, 1), I get acceptable results.
 [2009-11-29 07:06 UTC] cschmitz (Carsten Schmitz)
-Status: Open +Status: Verified
I can confirm that something is still fishy. When opening with Excel 2007, 'File error, data may be lost' error is shown, but the image is correctly shown. Complete example script: <?php require_once 'Spreadsheet/Excel/Writer.php'; // Creating a workbook $workbook = new Spreadsheet_Excel_Writer(); // sending HTTP headers $workbook->send('test.xls'); $sheet = &$workbook->addWorkSheet('test'); $file = "d:/passive.bmp"; $sheet->insertBitmap(0, 0, $file); // Let's send the file $workbook->close(); ?>