Home » File Formats » Spreadsheet_Excel_Writer » Bug #1791
Garbled output when space is inserted before opening <?php tag
Details
| Submitted | 2004-07-05 10:54 UTC |
|---|---|
| From | quinton dot parker at winner-net dot com |
| Status | Bogus |
| Package | Spreadsheet_Excel_Writer |
| PHP Version | 4.2.2 |
| OS | Windows 2003 server |
| Roadmaps | (Not assigned) |
Comments
[2004-07-05 10:54 UTC] quinton dot parker at winner-net dot com
Description:
------------
When you insert one or more spaces before the opening
<?php the outputted spreadsheet is garbled
and excel reports that the file is not recognisable.
We're using Spreadsheet Writer 0.8
Reproduce code:
---------------
<?php
// note the space before the <?php tag
require_once 'Spreadsheet/Excel/Writer.php';
$workbook = new Spreadsheet_Excel_Writer();
$format =& $workbook->addFormat(array('Size' => 10,
'Align' => 'center',
'Color' => 'white',
'Pattern' => 1,
'FgColor' => 'magenta'));
$worksheet =& $workbook->addWorksheet();
$worksheet->writeString(1, 0, "Magenta Hello", $format);
$workbook_name = 'hello.xls';
$workbook->send($workbook_name);
$workbook->close();
?>
Expected result:
----------------
The worksheet should open in Excel cleanly
Actual result:
--------------
Excel reports that the file is not in a recognisable format.
The spreadsheet shows garbled chars.
[2004-07-16 23:52 UTC] xnoguer at php dot net
Thank you for taking the time to write to us, but this is not
a bug.
Excel files are binary files, the space before the opening tag gets added to the Excel file and corrupts it. If you don't want to worry about that, use the output buffer functions.