Fixed bug with cell indexes in Row not being respected when rendering a Row

This commit is contained in:
Benny Gårdbo-Pedersen 2019-09-19 14:02:08 +02:00
parent 2d297e954b
commit ce7248c015

View File

@ -153,16 +153,17 @@ EOD;
*/ */
private function addNonEmptyRow(Worksheet $worksheet, Row $row) private function addNonEmptyRow(Worksheet $worksheet, Row $row)
{ {
$cellIndex = 0;
$rowStyle = $row->getStyle(); $rowStyle = $row->getStyle();
$rowIndex = $worksheet->getLastWrittenRowIndex() + 1; $rowIndex = $worksheet->getLastWrittenRowIndex() + 1;
$numCells = $row->getNumCells(); $numCells = max(array_keys($row->getCells()))+1;
$rowXML = '<row r="' . $rowIndex . '" spans="1:' . $numCells . '">'; $rowXML = '<row r="' . $rowIndex . '" spans="1:' . $numCells . '">';
foreach ($row->getCells() as $cell) { $cells = $row->getCells();
$rowXML .= $this->applyStyleAndGetCellXML($cell, $rowStyle, $rowIndex, $cellIndex); for($cell_index=0;$cell_index<$numCells;$cell_index++) {
$cellIndex++; if(isset($cells[$cell_index])) {
$rowXML .= $this->applyStyleAndGetCellXML($cells[$cell_index], $rowStyle, $rowIndex, $cell_index);
}
} }
$rowXML .= '</row>'; $rowXML .= '</row>';