PHPExcel icon indicating copy to clipboard operation
PHPExcel copied to clipboard

"No cells exist within the specified range" when using setIterateOnlyExistingCells(true)

Open rdlmda opened this issue 9 years ago • 2 comments

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:

captura de tela de 2015-12-08 18 01 28

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

rdlmda avatar Dec 08 '15 20:12 rdlmda

+1

codeachange avatar Aug 18 '16 12:08 codeachange

+1

shaqman avatar Oct 20 '17 03:10 shaqman