diff --git a/Classes/PHPExcel/Writer/CSV.php b/Classes/PHPExcel/Writer/CSV.php index cd536fb..17daf67 100644 --- a/Classes/PHPExcel/Writer/CSV.php +++ b/Classes/PHPExcel/Writer/CSV.php @@ -118,12 +118,16 @@ class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter { fwrite($fileHandle, "\xEF\xBB\xBF"); } - // Convert sheet to array - $cellsArray = $sheet->toArray('', $this->_preCalculateFormulas); + // Identify the range that we need to extract from the worksheet + $maxCol = $sheet->getHighestColumn(); + $maxRow = $sheet->getHighestRow(); // Write rows to file - foreach ($cellsArray as $row) { - $this->_writeLine($fileHandle, $row); + for($row = 1; $row <= $maxRow; ++$row) { + // Convert the row to an array... + $cellsArray = $sheet->rangeToArray('A'.$row.':'.$maxCol.$row,'', $this->_preCalculateFormulas); + // ... and write to the file + $this->_writeLine($fileHandle, $cellsArray[0]); } // Close file diff --git a/changelog.txt b/changelog.txt index 75185b7..d48f107 100644 --- a/changelog.txt +++ b/changelog.txt @@ -26,6 +26,7 @@ Fixed in SVN: - General: (MBaker) Fix to build to ensure that Examples are included with the documentation - General: (MBaker) Reduce cell caching overhead using dirty flag to ensure that cells are only rewritten to the cache if they have actually been changed +- General: (MBaker) Improved memory usage in CSV Writer - Bugfix: (MBaker) Work item 15459 - Invalid cell coordinate in Autofilter for Excel2007 Writer - Bugfix: (MBaker) Work item 15518 - PCLZip library issue - Bugfix: (MBaker) Work item 15537 - Excel2007 Reader canRead function bug