From a4d7997356a46c522ec7bfb2cda428a67d745b40 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Thu, 30 Apr 2015 23:55:27 +0100 Subject: [PATCH 1/7] 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 7f6240141..dea1503b8 100644 --- a/Classes/PHPExcel/Calculation/Functions.php +++ b/Classes/PHPExcel/Calculation/Functions.php @@ -496,7 +496,7 @@ public static function IS_NONTEXT($value = NULL) { * @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/7] 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 77c5d2e31..239cb4ff1 100644 --- a/Classes/PHPExcel/Worksheet/CellIterator.php +++ b/Classes/PHPExcel/Worksheet/CellIterator.php @@ -79,8 +79,7 @@ public function getIterateOnlyExistingCells() { * * @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/7] 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 2b0b57ae4..909f52575 100644 --- a/Classes/PHPExcel/Worksheet.php +++ b/Classes/PHPExcel/Worksheet.php @@ -1152,7 +1152,6 @@ public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 1, $pVa */ 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 @@ public function getCell($pCoordinate = 'A1') // 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/7] 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 000000000..8512a3e85 --- /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/7] 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 71ebfd00d..ca3f28d70 100644 --- a/Examples/16csv.php +++ b/Examples/16csv.php @@ -46,7 +46,6 @@ $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 @@ $callStartTime = microtime(true); $objReader = PHPExcel_IOFactory::createReader('CSV')->setDelimiter(',') ->setEnclosure('"') - ->setLineEnding("\r\n") ->setSheetIndex(0); $objPHPExcelFromCSV = $objReader->load(str_replace('.php', '.csv', __FILE__)); From bc20739906f8a5970f73788ee57ca432b1639e40 Mon Sep 17 00:00:00 2001 From: sevillacode Date: Sat, 14 Nov 2015 14:40:54 +0100 Subject: [PATCH 6/7] fix data type problem in INDEX function on LookupRef.php --- Classes/PHPExcel/Calculation/LookupRef.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Classes/PHPExcel/Calculation/LookupRef.php b/Classes/PHPExcel/Calculation/LookupRef.php index d86055121..ba3d74502 100644 --- a/Classes/PHPExcel/Calculation/LookupRef.php +++ b/Classes/PHPExcel/Calculation/LookupRef.php @@ -598,6 +598,16 @@ public static function MATCH($lookup_value, $lookup_array, $match_type = 1) */ public static function INDEX($arrayValues, $rowNum = 0, $columnNum = 0) { + + if(is_array($rowNum)){ + foreach($rowNum as $k=>$v){ + foreach($v as $k2=>$v2){ + $rowNum = $v2; + break 2; + } + } + } + if (($rowNum < 0) || ($columnNum < 0)) { return PHPExcel_Calculation_Functions::VALUE(); } From c022ce20a9c7d9830d8555dd0adac74c3726a7a3 Mon Sep 17 00:00:00 2001 From: sevillacode Date: Sun, 15 Nov 2015 12:02:39 +0100 Subject: [PATCH 7/7] fix row limitation in HLOOKUP --- Classes/PHPExcel/Calculation/LookupRef.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/PHPExcel/Calculation/LookupRef.php b/Classes/PHPExcel/Calculation/LookupRef.php index ba3d74502..52cad33cd 100644 --- a/Classes/PHPExcel/Calculation/LookupRef.php +++ b/Classes/PHPExcel/Calculation/LookupRef.php @@ -780,7 +780,7 @@ public static function HLOOKUP($lookup_value, $lookup_array, $index_number, $not } else { $f = array_keys($lookup_array); $firstRow = array_pop($f); - if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) { + if ((!is_array($lookup_array[$firstRow]))) { return PHPExcel_Calculation_Functions::REF(); } else { $columnKeys = array_keys($lookup_array[$firstRow]);