From a4d7997356a46c522ec7bfb2cda428a67d745b40 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Thu, 30 Apr 2015 23:55:27 +0100 Subject: [PATCH 1/5] version function --- Classes/PHPExcel/Calculation/Functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/PHPExcel/Calculation/Functions.php b/Classes/PHPExcel/Calculation/Functions.php index 7f62401..dea1503 100644 --- a/Classes/PHPExcel/Calculation/Functions.php +++ b/Classes/PHPExcel/Calculation/Functions.php @@ -496,7 +496,7 @@ class PHPExcel_Calculation_Functions { * @return string Version information */ public static function VERSION() { - return 'PHPExcel ##VERSION##, ##DATE##'; + return 'PHPExcel 1.8.1, 2015-04-30'; } // function VERSION() From c9f2ee522bdddf443845bdedb8e77e3ff8799c6e Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Fri, 1 May 2015 08:00:24 +0100 Subject: [PATCH 2/5] Abstract function PHPExcel_Worksheet_CellIterator::adjustForExistingOnlyRange() cannot contain body --- Classes/PHPExcel/Worksheet/CellIterator.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Classes/PHPExcel/Worksheet/CellIterator.php b/Classes/PHPExcel/Worksheet/CellIterator.php index 77c5d2e..239cb4f 100644 --- a/Classes/PHPExcel/Worksheet/CellIterator.php +++ b/Classes/PHPExcel/Worksheet/CellIterator.php @@ -79,8 +79,7 @@ abstract class PHPExcel_Worksheet_CellIterator * * @throws PHPExcel_Exception */ - abstract protected function adjustForExistingOnlyRange() { - } + abstract protected function adjustForExistingOnlyRange(); /** * Set the iterator to loop only existing cells From 0cdda0dc4288647832daf3d0cd8a5421e349f92f Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Mon, 4 May 2015 23:34:36 +0100 Subject: [PATCH 3/5] Fix to case-sensitivity in getCell() method when using a worksheet!cell reference --- Classes/PHPExcel/Worksheet.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Classes/PHPExcel/Worksheet.php b/Classes/PHPExcel/Worksheet.php index 2b0b57a..909f525 100644 --- a/Classes/PHPExcel/Worksheet.php +++ b/Classes/PHPExcel/Worksheet.php @@ -1152,7 +1152,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable */ public function getCell($pCoordinate = 'A1') { - $pCoordinate = strtoupper($pCoordinate); // Check cell collection if ($this->_cellCollection->isDataSet($pCoordinate)) { return $this->_cellCollection->getCacheData($pCoordinate); @@ -1161,7 +1160,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable // Worksheet reference? if (strpos($pCoordinate, '!') !== false) { $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true); - return $this->_parent->getSheetByName($worksheetReference[0])->getCell($worksheetReference[1]); + return $this->_parent->getSheetByName($worksheetReference[0])->getCell(strtoupper($worksheetReference[1])); } // Named range? From 8d3548adb09bf183747d7019b928faa92c159792 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Mon, 4 May 2015 23:40:44 +0100 Subject: [PATCH 4/5] New calculation example with cyclic formula --- Examples/13calculationCyclicFormulae.php | 97 ++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 Examples/13calculationCyclicFormulae.php diff --git a/Examples/13calculationCyclicFormulae.php b/Examples/13calculationCyclicFormulae.php new file mode 100644 index 0000000..8512a3e --- /dev/null +++ b/Examples/13calculationCyclicFormulae.php @@ -0,0 +1,97 @@ +'); + +date_default_timezone_set('Europe/London'); + +/** Include PHPExcel */ +require_once dirname(__FILE__) . '/../Classes/PHPExcel.php'; + + +// Create new PHPExcel object +echo date('H:i:s') , " Create new PHPExcel object" , EOL; +$objPHPExcel = new PHPExcel(); + +// Add some data, we will use some formulas here +echo date('H:i:s') , " Add some data and formulas" , EOL; +$objPHPExcel->getActiveSheet()->setCellValue('A1', '=B1') + ->setCellValue('A2', '=B2+1') + ->setCellValue('B1', '=A1+1') + ->setCellValue('B2', '=A2'); + +PHPExcel_Calculation::getInstance($objPHPExcel)->cyclicFormulaCount = 100; + +// Calculated data +echo date('H:i:s') , " Calculated data" , EOL; +for($row = 1; $row <= 2; ++$row) { + for ($col = 'A'; $col != 'C'; ++$col) { + if ((!is_null($formula = $objPHPExcel->getActiveSheet()->getCell($col.$row)->getValue())) && + ($formula[0] == '=')) { + echo 'Value of ' , $col , $row , ' [' , $formula , ']: ' , + $objPHPExcel->getActiveSheet()->getCell($col.$row)->getCalculatedValue() . EOL; + } + } +} + + +// Save Excel 2007 file +echo date('H:i:s') , " Write to Excel2007 format" , EOL; +$callStartTime = microtime(true); + +$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); + +// +// If we set Pre Calculated Formulas to true then PHPExcel will calculate all formulae in the +// workbook before saving. This adds time and memory overhead, and can cause some problems with formulae +// using functions or features (such as array formulae) that aren't yet supported by the calculation engine +// If the value is false (the default) for the Excel2007 Writer, then MS Excel (or the application used to +// open the file) will need to recalculate values itself to guarantee that the correct results are available. +// +//$objWriter->setPreCalculateFormulas(true); +$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); +$callEndTime = microtime(true); +$callTime = $callEndTime - $callStartTime; + +echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; +echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; +// Echo memory usage +echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; + + +// Echo memory peak usage +echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; + +// Echo done +echo date('H:i:s') , " Done writing file" , EOL; +echo 'File has been created in ' , getcwd() , EOL; From 049e85ae98a90869e1bc83087f755010e9223091 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 5 May 2015 01:10:25 +0100 Subject: [PATCH 5/5] Remove spurious setLineEnding() from csv example --- Examples/16csv.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/Examples/16csv.php b/Examples/16csv.php index 71ebfd0..ca3f28d 100644 --- a/Examples/16csv.php +++ b/Examples/16csv.php @@ -46,7 +46,6 @@ $callStartTime = microtime(true); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV')->setDelimiter(',') ->setEnclosure('"') - ->setLineEnding("\r\n") ->setSheetIndex(0) ->save(str_replace('.php', '.csv', __FILE__)); $callEndTime = microtime(true); @@ -61,7 +60,6 @@ echo date('H:i:s') , " Read from CSV format" , EOL; $callStartTime = microtime(true); $objReader = PHPExcel_IOFactory::createReader('CSV')->setDelimiter(',') ->setEnclosure('"') - ->setLineEnding("\r\n") ->setSheetIndex(0); $objPHPExcelFromCSV = $objReader->load(str_replace('.php', '.csv', __FILE__));