Fix `getCalculatedValue()` error with more than two INDIRECT
Closes #1115
This commit is contained in:
parent
95c8bb9918
commit
bbbfdb86a0
|
@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
- Best effort to support invalid colspan values in HTML reader - [878](https://github.com/PHPOffice/PhpSpreadsheet/pull/878)
|
- Best effort to support invalid colspan values in HTML reader - [878](https://github.com/PHPOffice/PhpSpreadsheet/pull/878)
|
||||||
- Fixes incorrect rows deletion [#868](https://github.com/PHPOffice/PhpSpreadsheet/issues/868)
|
- Fixes incorrect rows deletion [#868](https://github.com/PHPOffice/PhpSpreadsheet/issues/868)
|
||||||
- MATCH function fix (value search by type, stop search when match_type=-1 and unordered element encountered) - [Issue #1116](https://github.com/PHPOffice/PhpSpreadsheet/issues/1116)
|
- MATCH function fix (value search by type, stop search when match_type=-1 and unordered element encountered) - [Issue #1116](https://github.com/PHPOffice/PhpSpreadsheet/issues/1116)
|
||||||
|
- Fix `getCalculatedValue()` error with more than two INDIRECT [#1115](https://github.com/PHPOffice/PhpSpreadsheet/pull/1115)
|
||||||
|
|
||||||
## [1.8.2] - 2019-07-08
|
## [1.8.2] - 2019-07-08
|
||||||
|
|
||||||
|
|
|
@ -4140,6 +4140,9 @@ class Calculation
|
||||||
|
|
||||||
// if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
|
// if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
|
||||||
} elseif (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $token, $matches)) {
|
} elseif (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $token, $matches)) {
|
||||||
|
if ($pCellParent) {
|
||||||
|
$pCell->attach($pCellParent);
|
||||||
|
}
|
||||||
if (($cellID == 'AC99') || (isset($pCell) && $pCell->getCoordinate() == 'AC99')) {
|
if (($cellID == 'AC99') || (isset($pCell) && $pCell->getCoordinate() == 'AC99')) {
|
||||||
if (defined('RESOLVING')) {
|
if (defined('RESOLVING')) {
|
||||||
define('RESOLVING2', true);
|
define('RESOLVING2', true);
|
||||||
|
@ -4215,6 +4218,7 @@ class Calculation
|
||||||
}
|
}
|
||||||
unset($arg);
|
unset($arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = call_user_func_array($functionCall, $args);
|
$result = call_user_func_array($functionCall, $args);
|
||||||
|
|
||||||
if ($functionName != 'MKMATRIX') {
|
if ($functionName != 'MKMATRIX') {
|
||||||
|
|
|
@ -164,6 +164,22 @@ class CalculationTest extends TestCase
|
||||||
self::assertEquals("=cmd|'/C calc'!A0", $cell->getCalculatedValue());
|
self::assertEquals("=cmd|'/C calc'!A0", $cell->getCalculatedValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCellWithFormulaTwoIndirect()
|
||||||
|
{
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$workSheet = $spreadsheet->getActiveSheet();
|
||||||
|
$cell1 = $workSheet->getCell('A1');
|
||||||
|
$cell1->setValue('2');
|
||||||
|
$cell2 = $workSheet->getCell('B1');
|
||||||
|
$cell2->setValue('3');
|
||||||
|
$cell2 = $workSheet->getCell('C1');
|
||||||
|
$cell2->setValue('4');
|
||||||
|
$cell3 = $workSheet->getCell('D1');
|
||||||
|
$cell3->setValue('=SUM(INDIRECT("A"&ROW()),INDIRECT("B"&ROW()),INDIRECT("C"&ROW()))');
|
||||||
|
|
||||||
|
self::assertEquals('9', $cell3->getCalculatedValue());
|
||||||
|
}
|
||||||
|
|
||||||
public function testBranchPruningFormulaParsingSimpleCase()
|
public function testBranchPruningFormulaParsingSimpleCase()
|
||||||
{
|
{
|
||||||
$calculation = Calculation::getInstance();
|
$calculation = Calculation::getInstance();
|
||||||
|
|
Loading…
Reference in New Issue