mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2025-02-06 09:49:24 +03:00
Fix to allow calculate formula against a workbook, without passing in a cell
This commit is contained in:
parent
f6a2107856
commit
49d123e910
@ -2720,10 +2720,16 @@ class PHPExcel_Calculation
|
|||||||
$this->_debugLog->clearLog();
|
$this->_debugLog->clearLog();
|
||||||
$this->cyclicReferenceStack->clear();
|
$this->cyclicReferenceStack->clear();
|
||||||
|
|
||||||
|
if ($this->workbook !== null && $cellID === null && $pCell === null) {
|
||||||
|
$cellID = 'A1';
|
||||||
|
$pCell = $this->workbook->getActiveSheet()->getCell($cellID);
|
||||||
|
} else {
|
||||||
// Disable calculation cacheing because it only applies to cell calculations, not straight formulae
|
// Disable calculation cacheing because it only applies to cell calculations, not straight formulae
|
||||||
// But don't actually flush any cache
|
// But don't actually flush any cache
|
||||||
$resetCache = $this->getCalculationCacheEnabled();
|
$resetCache = $this->getCalculationCacheEnabled();
|
||||||
$this->calculationCacheEnabled = false;
|
$this->calculationCacheEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Execute the calculation
|
// Execute the calculation
|
||||||
try {
|
try {
|
||||||
$result = self::unwrapResult($this->_calculateFormulaValue($formula, $cellID, $pCell));
|
$result = self::unwrapResult($this->_calculateFormulaValue($formula, $cellID, $pCell));
|
||||||
@ -2731,8 +2737,10 @@ class PHPExcel_Calculation
|
|||||||
throw new PHPExcel_Calculation_Exception($e->getMessage());
|
throw new PHPExcel_Calculation_Exception($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->workbook === null) {
|
||||||
// Reset calculation cacheing to its previous state
|
// Reset calculation cacheing to its previous state
|
||||||
$this->calculationCacheEnabled = $resetCache;
|
$this->calculationCacheEnabled = $resetCache;
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user