From 2caeb221227d1ef1e4ec2128343746ebc71ef6d4 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sat, 22 Feb 2014 12:30:36 +0000 Subject: [PATCH] Bugfix: Work item CP20760 - Formula references to cell on another sheet in ODS files --- Classes/PHPExcel/Reader/OOCalc.php | 9 +++++---- changelog.txt | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Classes/PHPExcel/Reader/OOCalc.php b/Classes/PHPExcel/Reader/OOCalc.php index 3eda756a..01a34c15 100644 --- a/Classes/PHPExcel/Reader/OOCalc.php +++ b/Classes/PHPExcel/Reader/OOCalc.php @@ -617,22 +617,23 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce if ($hasCalculatedValue) { $type = PHPExcel_Cell_DataType::TYPE_FORMULA; -// echo 'Formula: '.$cellDataFormula.'
'; +// echo 'Formula: ', $cellDataFormula, PHP_EOL; $cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1); $temp = explode('"',$cellDataFormula); $tKey = false; foreach($temp as &$value) { // Only replace in alternate array entries (i.e. non-quoted blocks) if ($tKey = !$tKey) { - $value = preg_replace('/\[\.(.*):\.(.*)\]/Ui','$1:$2',$value); - $value = preg_replace('/\[\.(.*)\]/Ui','$1',$value); + $value = preg_replace('/\[(.+)\.(.*)\]/Ui','$1!$2',$value); // Cell reference in another sheet + $value = preg_replace('/\[\.(.*):\.(.*)\]/Ui','$1:$2',$value); // Cell range reference + $value = preg_replace('/\[\.(.*)\]/Ui','$1',$value); // Simple cell reference $value = PHPExcel_Calculation::_translateSeparator(';',',',$value,$inBraces); } } unset($value); // Then rebuild the formula string $cellDataFormula = implode('"',$temp); -// echo 'Adjusted Formula: '.$cellDataFormula.'
'; +// echo 'Adjusted Formula: ', $cellDataFormula, PHP_EOL; } $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? diff --git a/changelog.txt b/changelog.txt index 8d40e46a..8d936307 100644 --- a/changelog.txt +++ b/changelog.txt @@ -48,6 +48,7 @@ Fixed in develop branch for release v1.8.0: - Bugfix: (MBaker) Work Item GH-290 - AdvancedValueBinder "Division by zero"-error - Bugfix: (MBaker) Work Item CP20604 - Adding Sheet to Workbook Bug - Bugfix: (MBaker) Work item CP20703 - Calculation engine incorrectly evaluates empty cells as #VALUE +- Bugfix: (MBaker) Work item CP20760 - Formula references to cell on another sheet in ODS files - Feature: (amerov) - Implementation of the Excel HLOOKUP() function - Feature: (MBaker) - Added "Quote Prefix" to style settings (Excel2007 Reader and Writer only) - Feature: (MBaker) - Added Horizontal FILL alignment for Excel5 and Excel2007 Readers/Writers, and Horizontal DISTRIBUTED alignment for Excel2007 Reader/Writer