Speed boost and memory reduction in the Worksheet toArray() method.
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@66403 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
b321f33fed
commit
59b831c4f1
|
@ -2150,20 +2150,24 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||
// Garbage collect...
|
||||
$this->garbageCollect();
|
||||
|
||||
// Identify the range that we need to extract from the worksheet
|
||||
$maxCol = $this->getHighestColumn();
|
||||
$maxRow = $this->getHighestRow();
|
||||
$maxCol++;
|
||||
|
||||
// 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
|
||||
for ($row = 1; $row <= $maxRow; ++$row) {
|
||||
$c = -1;
|
||||
foreach ($cellIterator as $cell) {
|
||||
++$c;
|
||||
$rRef = ($returnCellRef) ? $cell->getRow() : $r;
|
||||
$cRef = ($returnCellRef) ? $cell->getColumn() : $c;
|
||||
if (!is_null($cell)) {
|
||||
// Cell exists?
|
||||
// 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 {
|
||||
|
@ -2176,13 +2180,15 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||
|
||||
if ($formatData) {
|
||||
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
|
||||
$returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString($returnValue[$rRef][$cRef], $style->getNumberFormat()->getFormatCode());
|
||||
$returnValue[$row][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString($returnValue[$rRef][$cRef], $style->getNumberFormat()->getFormatCode());
|
||||
}
|
||||
} else {
|
||||
// Cell doesn't exist
|
||||
$returnValue[$rRef][$cRef] = $nullValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
|
|
|
@ -27,6 +27,7 @@ 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
|
||||
|
|
Loading…
Reference in New Issue