PHPExcel
PHPExcel copied to clipboard
"No cells exist within the specified range" when using setIterateOnlyExistingCells(true)
According to the documentation,
Setting the cell iterator’s setIterateOnlyExistingCells() to FALSE will loop all cells in the worksheet that can be available at that moment. This will create new cells if required and increase memory usage! Only use it if it is intended to loop all cells that are possibly available.
I have set it to false
but it gets me an error message:
Here's the sample code:
$objReader = new PHPExcel_Reader_OOCalc();
$objPHPExcel = $objReader->load("./test.ods");
$objWorksheet = $objPHPExcel->getActiveSheet();
echo '<table>' . PHP_EOL;
foreach ($objWorksheet->getRowIterator() as $row) {
echo '<tr>' . PHP_EOL;
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(true);
foreach ($cellIterator as $cell) {
echo '<td>' .
$cell->getValue() .
'</td>' . PHP_EOL;
}
echo '</tr>' . PHP_EOL;
}
echo '</table>' . PHP_EOL;
Here's the test spreadsheet I'm using: test.ods.zip
+1
+1