When converting worksheets to HTML in a loop, _calculateSpans() is called only for first sheet

Topics: Developer Forum
Oct 11, 2011 at 11:24 AM

First of all, thank you for this great library!

Now, to my problem.

Let's say we have an Excel file with multiple sheets and there are merged cells in all sheets. The following works as expected:

print $objWriter->generateSheetData();

But when you generate HTML only for selected sheet (for example in a loop), colspans and rowspans are rendered correctly only for the first sheet:

for($i = 0; $i < $sheet_count; $i++) {
print $objWriter->generateSheetData();

It seems like one way to fix this is to locate function generateSheetData() in HTML.php and change this line:

if (!$this->_spansAreCalculated) {

to this:
if ($this->_sheetIndex !== null || !$this->_spansAreCalculated) {

Is there a bug or am I using this library in a wrong way?

Jul 14 at 4:21 PM
Yes! This completely solved an issue I was having where I needed to be able to specify which sheets I was outputting, and the merged cells weren't resulting in colspans on any but the first sheet. Thank you paulih.

Please, someone, add this fix to the production code.