Bug #2942 [Com]: Problems with files with over 200 row / or 30kb of filesize
| From: | tomasz.rup@gmail.com | Date: | Wed, 01 Apr 2009 08:38:29 +0000 |
| Subject: | Bug #2942 [Com]: Problems with files with over 200 row / or 30kb of filesize | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-287@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=2942&edit=1
ID: 2942
Comment by: tomasz.rup@gmail.com
Reported By: alex dot petri at gmx dot de
Summary: Problems with files with over 200 row / or 30kb of
filesize
Status: Open
Type: Bug
Package: Spreadsheet_Excel_Writer
Operating System: Linux
PHP Version: 4.3.9
Roadmap Versions:
New Comment:
Test file:
require_once "Spreadsheet/Excel/Writer.php";
class xls {
/**
* @var Spreadsheet_Excel_Writer
*/
private $xls;
/**
* @var Spreadsheet_Excel_Writer_Worksheet
*/
private $sheet;
private $row = 0;
private $colDateMasks;
private function init($filename) {
$this->xls = new
Spreadsheet_Excel_Writer($filename);
$this->xls->setVersion(8);
$this->sheet =& $this->xls->addWorksheet('Test');
$this->sheet->setInputEncoding('iso-8859-1');
}
private function createRow($cols) {
for($col = 0; $col < $cols; $col++) {
$content = date($this->colDateMasks[$col],
strtotime('2009-01-01 00:00:00') + ($this->row + $col));
$this->sheet->writeString($this->row, $col,
$content);
}
$this->row++;
}
private function finalize() {
$this->xls->close();
}
public function test($filename, $cols, $rows,
$colDateMasks) {
$this->colDateMasks = $colDateMasks;
$this->init($filename);
for($row = 0; $row < $rows; $row++) {
$this->createRow($cols);
}
$this->finalize();
}
}
$xls = new xls;
$xls->test('test1.xls', 1, 201, array('Y-m-d H:i:s'));
unset($xls);
$xls = new xls;
$xls->test('test2.xls', 2, 137, array('Y-m-d H:i:s', 'H:i:s'));
This code produce 2 files without letters. First file broken
on row 201. Second on row 137. Both files have a size
above 14k
My configuration:
Linux
PHP 5.2.9
PEAR::Spreadsheet_Excel_Writer 0.9.1
Previous Comments:
------------------------------------------------------------------------
[2008-11-24 14:00:20] mek7
valli, thank you very much, you saved me a day and my hair, wow! :)
------------------------------------------------------------------------
[2007-11-20 05:25:32] valli
Try out the the patch in
http://pear.php.net/bugs/bug.php?id=1572
(Miso's patch)
You can also download the patched Workbook.php from
http://bugs.gentoo.org/attachment.cgi?id=136412
------------------------------------------------------------------------
[2007-09-28 05:34:42] vtsuper
I got the same problem with the others,
I believe the setVersion and setInputEncoding('utf-8') is not work all
the time
when I set
$file->setVersion(8);
$sheet->setInputEncoding('utf-8');
and the excel content with Chinese character then it works.
but if the excel with only English character then it didn't works.
will it has a update version soon?
------------------------------------------------------------------------
[2007-08-23 00:58:55] johnnz
Oops, further to my previous comment. I see that
_calculateSharedStringSizes in ExcelWorkbook does consider the split for
the continue record, but its either not yet implemented or not correctly
implemented. I am still looking at that bit. Whichever way, at the
moment the result is not correct.
------------------------------------------------------------------------
[2007-08-23 00:44:49] johnnz
I have narrowed down the problem. At this stage still trying to figure
out the fix. When using unicode and when the string table (BIFF8 0xFC
STT) grows bigger than the size limit it will require a continue record
(BIFF8 0x3C CONTINUE). The Excel format has some additional rules about
splitting strings and these are not considered by the BIFFWrite
_addContinue function. It splits the data and breaks the rules.
From the OpenOffice.org Documention of the Excel File Format ...
Unicode strings are split in a special way. At the beginning of each
CONTINUE record the option flags byte is repeated.
Only the character size flag will be set in this flags byte, the
Rich-Text flag and the Far-East flag are set to zero.
In each CONTINUE record it is possible that the character size changes
from 8-bit characters to 16-bit characters
and vice versa.
!Never a Unicode string is split until and including the first
character. That means, all header fields (string length,option flags,
optional Rich-Text size, and optional Far-East data size) and the first
character of the string have tooccur together in the leading record, or
have to be moved completely into the CONTINUE record.
!Formatting runs (➜2.5.1) cannot be split between their
components (character index and FONT record index). If a
string is split between two formatting runs, the option flags field
will not be repeated in the CONTINUE record
...
If you use non-unicode I guess you will avoid this problem.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://pear.php.net/bugs/bug.php?id=2942
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=2942&edit=1