Bugfix: Work item CP20760 - Formula references to cell on another sheet in ODS files

This commit is contained in:
Mark Baker 2014-02-22 12:30:36 +00:00
parent 8f265a9342
commit 2caeb22122
2 changed files with 6 additions and 4 deletions

View File

@ -617,22 +617,23 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
if ($hasCalculatedValue) { if ($hasCalculatedValue) {
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = PHPExcel_Cell_DataType::TYPE_FORMULA;
// echo 'Formula: '.$cellDataFormula.'<br />'; // echo 'Formula: ', $cellDataFormula, PHP_EOL;
$cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1); $cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1);
$temp = explode('"',$cellDataFormula); $temp = explode('"',$cellDataFormula);
$tKey = false; $tKey = false;
foreach($temp as &$value) { foreach($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks) // Only replace in alternate array entries (i.e. non-quoted blocks)
if ($tKey = !$tKey) { if ($tKey = !$tKey) {
$value = preg_replace('/\[\.(.*):\.(.*)\]/Ui','$1:$2',$value); $value = preg_replace('/\[(.+)\.(.*)\]/Ui','$1!$2',$value); // Cell reference in another sheet
$value = preg_replace('/\[\.(.*)\]/Ui','$1',$value); $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); $value = PHPExcel_Calculation::_translateSeparator(';',',',$value,$inBraces);
} }
} }
unset($value); unset($value);
// Then rebuild the formula string // Then rebuild the formula string
$cellDataFormula = implode('"',$temp); $cellDataFormula = implode('"',$temp);
// echo 'Adjusted Formula: '.$cellDataFormula.'<br />'; // echo 'Adjusted Formula: ', $cellDataFormula, PHP_EOL;
} }
$colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?

View File

@ -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 GH-290 - AdvancedValueBinder "Division by zero"-error
- Bugfix: (MBaker) Work Item CP20604 - Adding Sheet to Workbook Bug - 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 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: (amerov) - Implementation of the Excel HLOOKUP() function
- Feature: (MBaker) - Added "Quote Prefix" to style settings (Excel2007 Reader and Writer only) - 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 - Feature: (MBaker) - Added Horizontal FILL alignment for Excel5 and Excel2007 Readers/Writers, and Horizontal DISTRIBUTED alignment for Excel2007 Reader/Writer