mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-25 23:06:03 +03:00
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
@ -1661,10 +1661,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2
|
PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove autofilter
|
* Remove autofilter
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function removeAutoFilter()
|
public function removeAutoFilter()
|
||||||
@ -2150,36 +2150,42 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
// Garbage collect...
|
// Garbage collect...
|
||||||
$this->garbageCollect();
|
$this->garbageCollect();
|
||||||
|
|
||||||
// Loop through rows
|
// Identify the range that we need to extract from the worksheet
|
||||||
$r = -1;
|
$maxCol = $this->getHighestColumn();
|
||||||
$rowIterator = $this->getRowIterator();
|
$maxRow = $this->getHighestRow();
|
||||||
foreach ($rowIterator as $row) {
|
$maxCol++;
|
||||||
++$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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($formatData) {
|
// Loop through rows
|
||||||
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
|
for ($row = 1; $row <= $maxRow; ++$row) {
|
||||||
$returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString($returnValue[$rRef][$cRef], $style->getNumberFormat()->getFormatCode());
|
$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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,14 @@ Fixed in SVN:
|
|||||||
- Feature: (MBaker) Provide option to use PCLZip as an alternative to ZipArchive.
|
- 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
|
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) 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 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 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 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) 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: (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: (MB) Work item 11583 - Need method for removing autoFilter
|
||||||
- Bugfix: (MBaker) Work item 15029 - coordinateFromString throws exception for rows greater than 99,999
|
- Bugfix: (MBaker) Work item 15029 - coordinateFromString throws exception for rows greater than 99,999
|
||||||
|
|
||||||
|
|
||||||
2010-12-10 (v1.7.5):
|
2010-12-10 (v1.7.5):
|
||||||
|
Loading…
Reference in New Issue
Block a user