diff --git a/Classes/PHPExcel/Worksheet.php b/Classes/PHPExcel/Worksheet.php index 3ba25e4a..64096f91 100644 --- a/Classes/PHPExcel/Worksheet.php +++ b/Classes/PHPExcel/Worksheet.php @@ -1661,10 +1661,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2 ); } - + /** * Remove autofilter - * + * * @return PHPExcel_Worksheet */ public function removeAutoFilter() @@ -2150,36 +2150,42 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable // Garbage collect... $this->garbageCollect(); - // Loop through rows - $r = -1; - $rowIterator = $this->getRowIterator(); - foreach ($rowIterator as $row) { - ++$r; - $cellIterator = $row->getCellIterator(); - $cellIterator->setIterateOnlyExistingCells(true); // Loop through each cell in the current row - $c = -1; - foreach ($cellIterator as $cell) { - ++$c; - $rRef = ($returnCellRef) ? $cell->getRow() : $r; - $cRef = ($returnCellRef) ? $cell->getColumn() : $c; - if (!is_null($cell)) { - // Cell exists? - if ($cell->getValue() instanceof PHPExcel_RichText) { - $returnValue[$rRef][$cRef] = $cell->getValue()->getPlainText(); - } else { - if ($calculateFormulas) { - $returnValue[$rRef][$cRef] = $cell->getCalculatedValue(); - } else { - $returnValue[$rRef][$cRef] = $cell->getValue(); - } - } + // Identify the range that we need to extract from the worksheet + $maxCol = $this->getHighestColumn(); + $maxRow = $this->getHighestRow(); + $maxCol++; - if ($formatData) { - $style = $this->_parent->getCellXfByIndex($cell->getXfIndex()); - $returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString($returnValue[$rRef][$cRef], $style->getNumberFormat()->getFormatCode()); + // Loop through rows + for ($row = 1; $row <= $maxRow; ++$row) { + $c = -1; + // Loop through columns in the current row + for ($col = 'A'; $col != $maxCol; ++$col) { + $rRef = ($returnCellRef) ? $row : $row-1; + $cRef = ($returnCellRef) ? $col : ++$c; + // Using getCell() will create a new cell if it doesn't already exist. We don't want that to happen + // so we test and retrieve directly against _cellCollection + if ($this->_cellCollection->isDataSet($col.$row)) { + // Cell exists + $cell = $this->_cellCollection->getCacheData($col.$row); + if ($cell->getValue() !== null) { + if ($cell->getValue() instanceof PHPExcel_RichText) { + $returnValue[$rRef][$cRef] = $cell->getValue()->getPlainText(); + } else { + if ($calculateFormulas) { + $returnValue[$rRef][$cRef] = $cell->getCalculatedValue(); + } else { + $returnValue[$rRef][$cRef] = $cell->getValue(); + } + } + + if ($formatData) { + $style = $this->_parent->getCellXfByIndex($cell->getXfIndex()); + $returnValue[$row][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString($returnValue[$rRef][$cRef], $style->getNumberFormat()->getFormatCode()); + } + } else { + // Cell doesn't exist + $returnValue[$rRef][$cRef] = $nullValue; } - } else { - $returnValue[$rRef][$cRef] = $nullValue; } } } diff --git a/changelog.txt b/changelog.txt index 9b709624..c94b29a3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -27,13 +27,14 @@ Fixed in SVN: - Feature: (MBaker) Provide option to use PCLZip as an alternative to ZipArchive. This allows the writing of Excel2007 files, even without ZipArchive enabled (it does require zlib), or when php_zip is one of the buggy PHP 5.2.6 or 5.2.8 versions - Feature: (MBaker) Work item 14979 - Added listWorksheetNames() method to Readers that support multiple worksheets in a workbook, allowing a user to extract a list of all the worksheet names from a file without parsing/loading the whole file. +- Feature: (MBaker) Speed boost and memory reduction in the Worksheet toArray() method. - Bugfix: (MBaker) Work item 14888 - Simple =IF() formula disappears - Bugfix: (MBaker) Work item 14898 - PHP Warning: preg_match(): Compilation failed: PCRE does not support \\L, \\l, \\N, \\P, \\p, \\U, \\u, or \\X - Bugfix: (MBaker) Work item 14901 - VLOOKUP choking on parameters in PHPExcel.1.7.5/PHPExcel_Writer_Excel2007 - Bugfix: (MBaker) Work item 14973 - PHPExcel_Cell::isInRange() incorrect results - offset by one column - Bugfix: (MBaker) Treat CodePage of 0 as CP1251 (for .xls files written by applications that don't set the CodePage correctly, such as Apple Numbers) -- Bugfix: (MB) Work item 11583 - Need method for removing autoFilter -- Bugfix: (MBaker) Work item 15029 - coordinateFromString throws exception for rows greater than 99,999 +- Bugfix: (MB) Work item 11583 - Need method for removing autoFilter +- Bugfix: (MBaker) Work item 15029 - coordinateFromString throws exception for rows greater than 99,999 2010-12-10 (v1.7.5):