Bug #16025 [Com]: MERGEDCELLS record split by CONTINUE record
| From: | greeesha | Date: | Wed, 02 Jun 2010 10:40:05 +0000 |
| Subject: | Bug #16025 [Com]: MERGEDCELLS record split by CONTINUE record | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-3843@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=16025&edit=1
ID: 16025
Comment by: greeesha
Reported By: greeesha at gmail dot com
Summary: MERGEDCELLS record split by CONTINUE record
Status: Open
Type: Bug
Package: Spreadsheet_Excel_Writer
Operating System: openSUSE 10.2 (i586)
Package Version: 0.9.1
PHP Version: Irrelevant
New Comment:
Got same problem with setMerge, and had some work to isolate it and
fix, instead quality search fo
My solution was found in PERL Spreadsheet::WriteExcel package. There
was no any "CONTINUE" blocks. So here my complete _storeMergedCells()
function to Worksheet.php file.
function _storeMergedCells() {
// if there are no merged cell ranges set, return
if (count($this->_merged_ranges) == 0) {
return;
}
$record = 0x00E5;
$length = 0x000A;
foreach ($this->_merged_ranges as $range) {
$header = pack('vv', $record, $length);
$data = pack('vvvvv', 1, $range[0], $range[2], $range[1],
$range[3]);
$this->_append($header . $data);
}
}
It works for me on Excel 2003 on about 3000 pairs of merged rows.
Previous Comments:
------------------------------------------------------------------------
[2009-03-12 11:37:05] bjaenichen
The following patch has been added/updated:
Patch Name: merged_cells_patch
URL: #patch
bug:16025;patch:merged_cells_patch;revision:1236857825;
------------------------------------------------------------------------
[2009-03-12 11:36:15] bjaenichen
Description:
------------
If more mergedcells ranges declared as record size limit allows in one
MERGEDCELLS-record a CONTINUE-record will split MERGEDCELLS-record into
pieces.
This is not supported by MS-Excel, OpenOffice fileformat documentation
describes how to store it correctly:
"If the record size exceeds the limit, it is not continued with a
CONTINUE record, but another self-contained MERGEDCELLS
record is started. The limit of 8224 bytes per record results in a
maximum number of 1027 merged ranges."
Attached patch will fix Worksheet.php.
Test script:
---------------
<?PHP
include "Writer.php";
$wb = new Spreadsheet_Excel_Writer("/tmp/test_merged_cells.xls");
$wb->setVersion(8);
$wb->_codepage = 0x4b0;
$wb->worksheetcounter = 0;
$wb->localworksheets[$wb->worksheetcounter] =
&$wb->addWorksheet("Table".$wb->worksheetcounter);
for($i = 0; $i < 1030; $i++)
{
$wb->localworksheets[$wb->worksheetcounter]->writeString($i, 0,
$i);
$wb->localworksheets[$wb->worksheetcounter]->setMerge($i, 0, $i,
1);
}
$wb->close();
?>
Expected result:
----------------
MS-Excel opens the resulting XLS-testfile without any warning.
Actual result:
--------------
MS-Excel crashes if opening the resulting XLS-testfile.
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=16025&edit=1