Minor fixes to cyclic references in formulae

This commit is contained in:
MarkBaker 2014-09-13 16:12:45 +01:00
parent 01d6f7f1d5
commit 37b4d18d45
1 changed files with 6 additions and 3 deletions

View File

@ -2374,7 +2374,7 @@ class PHPExcel_Calculation {
* @throws PHPExcel_Calculation_Exception
*/
public function _calculateFormulaValue($formula, $cellID=null, PHPExcel_Cell $pCell = null) {
$cellValue = '';
$cellValue = null;
// Basic validation that this is indeed a formula
// We simply return the cell value if not
@ -2392,20 +2392,23 @@ class PHPExcel_Calculation {
if (($wsTitle{0} !== "\x00") && ($this->_cyclicReferenceStack->onStack($wsTitle.'!'.$cellID))) {
if ($this->cyclicFormulaCount <= 0) {
$this->_cyclicFormulaCell = '';
return $this->_raiseFormulaError('Cyclic Reference in Formula');
} elseif (($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) &&
($this->_cyclicFormulaCell == $wsTitle.'!'.$cellID)) {
$this->_cyclicFormulaCell = '';
return $cellValue;
} elseif ($this->_cyclicFormulaCell == $wsTitle.'!'.$cellID) {
++$this->_cyclicFormulaCount;
if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
$this->_cyclicFormulaCell = '';
return $cellValue;
}
} elseif ($this->_cyclicFormulaCell == '') {
$this->_cyclicFormulaCell = $wsTitle.'!'.$cellID;
if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
return $cellValue;
}
$this->_cyclicFormulaCell = $wsTitle.'!'.$cellID;
}
}