From 506eabdbf75d959c20c8eab3a7abcf88a3a6499b Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Fri, 26 Nov 2010 13:31:51 +0000 Subject: [PATCH] Minor performance tweaks git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@64389 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Calculation.php | 10 ++++++---- Classes/PHPExcel/Writer/Excel2007.php | 4 ++-- Classes/PHPExcel/Writer/Excel2007/Worksheet.php | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Classes/PHPExcel/Calculation.php b/Classes/PHPExcel/Calculation.php index 8fe6746c..cfe72f13 100644 --- a/Classes/PHPExcel/Calculation.php +++ b/Classes/PHPExcel/Calculation.php @@ -3517,7 +3517,8 @@ class PHPExcel_Calculation { // Extract range $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange); $pRange = $pSheet->getTitle().'!'.$pRange; - if (count($aReferences) == 1) { + if (!isset($aReferences[1])) { + // Single cell in range list($currentCol,$currentRow) = sscanf($aReferences[0],'%[A-Z]%d'); if ($pSheet->cellExists($aReferences[0])) { $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog); @@ -3525,7 +3526,7 @@ class PHPExcel_Calculation { $returnValue[$currentRow][$currentCol] = null; } } else { - // Extract cell data + // Extract cell data for all cells in the range foreach ($aReferences as $reference) { // Extract range list($currentCol,$currentRow) = sscanf($reference,'%[A-Z]%d'); @@ -3589,7 +3590,8 @@ class PHPExcel_Calculation { // Extract range $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange); - if (count($aReferences) == 1) { + if (!isset($aReferences[1])) { + // Single cell in range list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]); if ($pSheet->cellExists($aReferences[0])) { $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog); @@ -3597,7 +3599,7 @@ class PHPExcel_Calculation { $returnValue[$currentRow][$currentCol] = null; } } else { - // Extract cell data + // Extract cell data for all cells in the range foreach ($aReferences as $reference) { // Extract range list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($reference); diff --git a/Classes/PHPExcel/Writer/Excel2007.php b/Classes/PHPExcel/Writer/Excel2007.php index 9a9464a2..55c90e1b 100644 --- a/Classes/PHPExcel/Writer/Excel2007.php +++ b/Classes/PHPExcel/Writer/Excel2007.php @@ -172,7 +172,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter * @param string $pPartName Writer part name * @return PHPExcel_Writer_Excel2007_WriterPart */ - function getWriterPart($pPartName = '') { + public function getWriterPart($pPartName = '') { if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) { return $this->_writerParts[strtolower($pPartName)]; } else { @@ -363,7 +363,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter * @throws Exception */ public function getPHPExcel() { - if ($this->_spreadSheet !== NULL) { + if ($this->_spreadSheet !== null) { return $this->_spreadSheet; } else { throw new Exception("No PHPExcel assigned."); diff --git a/Classes/PHPExcel/Writer/Excel2007/Worksheet.php b/Classes/PHPExcel/Writer/Excel2007/Worksheet.php index 24b3d717..7140fdcb 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Worksheet.php +++ b/Classes/PHPExcel/Writer/Excel2007/Worksheet.php @@ -858,7 +858,8 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ $cellsByRow[$cellAddress[1]][] = $cellID; } - for ($currentRow = 1; $currentRow <= $highestRow; ++$currentRow) { + $currentRow = 0; + while($currentRow++ < $highestRow) { // Get row dimension $rowDimension = $pSheet->getRowDimension($currentRow);