Re: Structures_DataGrid_Renderer_XLS: I just get empty files
| From: | (Michael Mauch) | Date: | Wed, 28 Feb 2007 18:43:27 +0000 |
| Subject: | Re: Structures_DataGrid_Renderer_XLS: I just get empty files | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-26691@lists.php.net to get a copy of this message | ||
Markus Ernst wrote:
> When opening the resulting file,
> - Excel shows a broken file warning and displays until row 105, Col 2
> - OpenOffice starts displaying distorted characters at the same column,
> and *** ERROR IN SST *** a few rows later.
I can see garbage characters in OpenOffice, but no "ERROR IN SST". And
the lines after the garbage are missing.
> Some more facts:
> - It happens with utf-8 encoding, but not with default encoding
> (iso-8859-1).
I tried with many encodings, but the only working one was
'encoding' => ''
> - As the example shows, it also happens if no special characters are in
> the data.
Yes.
> - There seems to be a relationship between the total amount of text in
> unique field contents: If you change the second column contents from
> $i.'this' to 'this', the error starts in row 127; now change the third
> column contents from $i.'is' to $i.'iss', then the error starts in row 123.
>
> Do you think I should file a bug with this info? If yes, does it belong
> to Structures_DataGrid_Renderer_XLS or rather to Spreadsheet_Excel_Writer?
Yes, I think you should file a bug report, but I'm not sure for which
one. I see the same problem with Spreadsheet_Excel_Writer alone:
<?php
require_once 'Spreadsheet/Excel/Writer.php';
$workbook = new Spreadsheet_Excel_Writer();
$workbook->setVersion(8);
$worksheet =& $workbook->addWorksheet('My first worksheet');
// $worksheet->setInputEncoding('UTF-16LE');
// $worksheet->setInputEncoding('UTF-8LE');
// $worksheet->setInputEncoding('ISO-8859-7');
$worksheet->setInputEncoding('UTF-8');
// $worksheet->setInputEncoding('ISO-8859-1');
// $worksheet->setInputEncoding('windows-1251');
$data = array();
for ($i=0; $i<500; $i++) {
$data[] = array($i.'hello there', $i.'this', $i.'is',
$i.'a', $i.'test');
}
for ($i=0; $i<500; $i++) {
for($j=0; $j<count($data[$i]); $j++) {
$worksheet->write($i, $j, $data[$i][$j]);
}
}
$workbook->close();
?>
There the problem is at line 198.
If I omit that $workbook->setVersion(8), it works. Alas, setVersion() is
not documented on
http://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.php
and I can see in Spreadsheet/Excel/Writer/Workbook.php:
/**
* Sets the BIFF version.
* This method exists just to access experimental functionality
* from BIFF8. It will be deprecated !
* Only possible value is 8 (Excel 97/2000).
* For any other value it fails silently.
*
* @access public
* @param integer $version The BIFF version
*/
function setVersion($version)
On the other hand, Structures/DataGrid/Renderer/XLS.php has a line
$this->_workbook->setVersion(8);
And there's apparently no way to turn that off. Probably you really want
setVersion(8), because you wrote it in your example.
Regards...
Michael