Reputation: 7183
I'm using PEAR's Spreadsheet_Excel_Writer to, well, write Excel files. I'm encountering a rather odd error, though. Without fail, my script stops merging cells around row ~260, plus/minus maybe 2.
I am reading values from a database with a variable starting position. Though the row at which the merging stops to work is not the same for every list of database entries, it does not vary when the script is run from the same starting position.
I understand that I'm not making any sense at all, so attached is an example generated Excel file. ;) Notice how from line 261 onward, the cells don't merge as they do in the several rows prior.
I am at a complete loss as to what can be causing this. My script is very large and database-dependent too, so it's not very well suited for providing here, but I am hoping someone here might have experienced this before. Is there some Excel limitation I'm encountering that I don't know about?
Thanks!
Upvotes: 0
Views: 1141
Reputation: 483
find 2 resolves:
Just use Worksheet::mergeCells()
with same parameters. (But fill cell before use merge)
replace _storeMergedCells()
function in Worksheet.inc
to:
function _storeMergedCells()
{
// if there are no merged cell ranges set, return
if (count($this->_merged_ranges) == 0) {
return;
}
if(count($this->_merged_ranges) > 255) {
$_merged_ranges_chunks = array_chunk($this->_merged_ranges, 255);
foreach ($_merged_ranges_chunks as $chunk) {
$this->_merged_ranges = $chunk;
$this->_storeMergedCells();
}
} else {
$record = 0x00E5;
$length = 2 + count($this->_merged_ranges) * 8;
$header = pack('vv', $record, $length);
$data = pack('v', count($this->_merged_ranges));
foreach ($this->_merged_ranges as $range) {
$data .= pack('vvvv', $range[0], $range[2], $range[1], $range[3]);
}
$this->_append($header . $data);
}
}
Upvotes: 0