Edit report at https://pear.php.net/bugs/bug.php?id=16025&edit=1

ID: 16025
Updated by: [email protected]
Reported By: bernd dot jaenichen at globalpark dot com
Summary: MERGEDCELLS record split by CONTINUE record
-Status: Open
+Status: Closed
Type: Bug
Package: Spreadsheet_Excel_Writer
Operating System: openSUSE 10.2 (i586)
Package Version: 0.9.1
PHP Version: Irrelevant
-Assigned To:
+Assigned To: doconnor
Roadmap Versions:
New Comment:

-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: doconnor
This bug has been fixed in SVN.

If this was a documentation problem, the fix will appear on pear.php.net
by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should
be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.

Previous Comments:

[2010-06-02 10:36:17] greeesha

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) {
$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],
$this->_append($header . $data);

It works for me on Excel 2003 on about 3000 pairs of merged rows.


[2009-03-12 11:37:05] bjaenichen

The following patch has been added/updated:

Patch Name: merged_cells_patch
URL: #patch


[2009-03-12 11:36:15] bjaenichen

If more mergedcells ranges declared as record size limit allows in one
MERGEDCELLS-record a CONTINUE-record will split MERGEDCELLS-record into

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:
include "Writer.php";
$wb = new Spreadsheet_Excel_Writer("/tmp/test_merged_cells.xls");
$wb->_codepage = 0x4b0;
$wb->worksheetcounter = 0;
$wb->localworksheets[$wb->worksheetcounter] =
for($i = 0; $i < 1030; $i++)
$wb->localworksheets[$wb->worksheetcounter]->writeString($i, 0,
$wb->localworksheets[$wb->worksheetcounter]->setMerge($i, 0, $i,

Expected result:
MS-Excel opens the resulting XLS-testfile without any warning.

Actual result:
MS-Excel crashes if opening the resulting XLS-testfile.


Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
postedDec 10, '11 at 2:08a
activeDec 10, '11 at 2:08a

1 user in discussion

Daniel Oconnor: 1 post



site design / logo © 2023 Grokbase