Bugfix to ensure that current cell is maintained when executing formula calculations

This commit is contained in:
MarkBaker 2014-07-15 23:33:06 +01:00
parent c6d0a4d3d0
commit 87be8d3d8e
2 changed files with 11 additions and 0 deletions

View File

@ -194,6 +194,8 @@ class PHPExcel_Calculation {
*/ */
private $_cyclicReferenceStack; private $_cyclicReferenceStack;
private $_cellStack = array();
/** /**
* Current iteration counter for cyclic formulae * Current iteration counter for cyclic formulae
* If the value is 0 (or less) then cyclic formulae will throw an exception, * If the value is 0 (or less) then cyclic formulae will throw an exception,
@ -2240,9 +2242,17 @@ class PHPExcel_Calculation {
} }
// Execute the calculation for the cell formula // Execute the calculation for the cell formula
$this->_cellStack[] = array(
'sheet' => $pCell->getWorksheet()->getTitle(),
'cell' => $pCell->getCoordinate(),
);
try { try {
$result = self::_unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell)); $result = self::_unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell));
$cellAddress = array_pop($this->_cellStack);
$this->_workbook->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);
} catch (PHPExcel_Exception $e) { } catch (PHPExcel_Exception $e) {
$cellAddress = array_pop($this->_cellStack);
$this->_workbook->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);
throw new PHPExcel_Calculation_Exception($e->getMessage()); throw new PHPExcel_Calculation_Exception($e->getMessage());
} }

View File

@ -25,6 +25,7 @@
Planned for v1.8.1 Planned for v1.8.1
- Bugfix: (goncons) Work Item GH-397 - Fix for Writing an Open Document cell with non-numeric formula - Bugfix: (goncons) Work Item GH-397 - Fix for Writing an Open Document cell with non-numeric formula
- Bugfix: (sarciszewski) Work Item GH-329 - Avoid potential divide by zero in basedrawing - Bugfix: (sarciszewski) Work Item GH-329 - Avoid potential divide by zero in basedrawing
- Bugfix: (MBaker) - Fix to ensure that current cell is maintained when executing formula calculations
- General: (MBaker) - Small performance improvement for autosize columns - General: (MBaker) - Small performance improvement for autosize columns
- Feature: (WiktrzGE) Work Item GH-404 - Methods to manage most of the existing options for Chart Axis, Major Grid-lines and Minor Grid-lines - Feature: (WiktrzGE) Work Item GH-404 - Methods to manage most of the existing options for Chart Axis, Major Grid-lines and Minor Grid-lines
- Feature: (frost-nzcr4) Work Item GH-403 - ODS read/write comments in the cell - Feature: (frost-nzcr4) Work Item GH-403 - ODS read/write comments in the cell