From 94e3dc3fd2721590c5e70462d6b80b2518bf3159 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Wed, 1 Jun 2011 23:09:12 +0000 Subject: [PATCH] Improved speed and memory usage in Excel5 Writer git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@74786 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Writer/Excel5/Worksheet.php | 26 +++++++++----------- changelog.txt | 1 + 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Classes/PHPExcel/Writer/Excel5/Worksheet.php b/Classes/PHPExcel/Writer/Excel5/Worksheet.php index 7f99e25e..8efe3153 100644 --- a/Classes/PHPExcel/Writer/Excel5/Worksheet.php +++ b/Classes/PHPExcel/Writer/Excel5/Worksheet.php @@ -236,24 +236,20 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $this->_outline_on = 1; // calculate values for DIMENSIONS record - $minR = $maxR = 1; - $minC = $maxC = '1A'; - foreach ($this->_phpSheet->getCellCollection(false) as $cellID) { - list($c,$r) = sscanf($cellID,'%[A-Z]%d'); - $minR = min($minR,$r); - $maxR = max($maxR,$r); - $C = strlen($c).$c; - $minC = min($minC,$C); - $maxC = max($maxC,$C); - } + $minR = 1; + $minC = 'A'; + + $maxR = $this->_phpSheet->getHighestRow(); + $maxC = $this->_phpSheet->getHighestColumn(); + // Determine lowest and highest column and row - $this->_firstRowIndex = ($minR > 65535) ? $minR: 65535; - $this->_lastRowIndex = ($maxR > 65535) ? $maxR : 65535; +// $this->_firstRowIndex = ($minR > 65535) ? 65535 : $minR; + $this->_lastRowIndex = ($maxR > 65535) ? 65535 : $maxR ; - $this->_firstColumnIndex = PHPExcel_Cell::columnIndexFromString(substr($minC,1)); - $this->_lastColumnIndex = PHPExcel_Cell::columnIndexFromString(substr($maxC,1)); + $this->_firstColumnIndex = PHPExcel_Cell::columnIndexFromString($minC); + $this->_lastColumnIndex = PHPExcel_Cell::columnIndexFromString($maxC); - if ($this->_firstColumnIndex > 255) $this->_firstColumnIndex = 255; +// if ($this->_firstColumnIndex > 255) $this->_firstColumnIndex = 255; if ($this->_lastColumnIndex > 255) $this->_lastColumnIndex = 255; $this->_countCellStyleXfs = count($phpSheet->getParent()->getCellStyleXfCollection()); diff --git a/changelog.txt b/changelog.txt index 14d6aebe..71cc9029 100644 --- a/changelog.txt +++ b/changelog.txt @@ -27,6 +27,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 +- General: (MBaker) Improved speed and memory usage in Excel5 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