Fix for issue #2614 (#2615)

* Fix for issue #2614

* Unit test (in ISREF() tests) that covers issue #2614
This commit is contained in:
Mark Baker 2022-02-22 09:06:10 +01:00 committed by GitHub
parent c9f948bd91
commit 3c57d9e291
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -3895,12 +3895,12 @@ class Calculation
// so we store the parent worksheet so that we can re-attach it when necessary // so we store the parent worksheet so that we can re-attach it when necessary
$pCellParent = ($cell !== null) ? $cell->getWorksheet() : null; $pCellParent = ($cell !== null) ? $cell->getWorksheet() : null;
$regexpMatchString = '/^(' . self::CALCULATION_REGEXP_FUNCTION . $regexpMatchString = '/^(' . self::CALCULATION_REGEXP_STRING .
'|' . self::CALCULATION_REGEXP_FUNCTION .
'|' . self::CALCULATION_REGEXP_CELLREF . '|' . self::CALCULATION_REGEXP_CELLREF .
'|' . self::CALCULATION_REGEXP_COLUMN_RANGE . '|' . self::CALCULATION_REGEXP_COLUMN_RANGE .
'|' . self::CALCULATION_REGEXP_ROW_RANGE . '|' . self::CALCULATION_REGEXP_ROW_RANGE .
'|' . self::CALCULATION_REGEXP_NUMBER . '|' . self::CALCULATION_REGEXP_NUMBER .
'|' . self::CALCULATION_REGEXP_STRING .
'|' . self::CALCULATION_REGEXP_OPENBRACE . '|' . self::CALCULATION_REGEXP_OPENBRACE .
'|' . self::CALCULATION_REGEXP_DEFINEDNAME . '|' . self::CALCULATION_REGEXP_DEFINEDNAME .
'|' . self::CALCULATION_REGEXP_ERROR . '|' . self::CALCULATION_REGEXP_ERROR .

View File

@ -23,8 +23,9 @@ class IsRefTest extends AllSetupTeardown
$sheet->getCell('A8')->setValue('=ISREF(INDIRECT("' . $sheet->getTitle() . '" & "!" & "A1"))'); $sheet->getCell('A8')->setValue('=ISREF(INDIRECT("' . $sheet->getTitle() . '" & "!" & "A1"))');
$sheet->getCell('A9')->setValue('=ISREF(INDIRECT("A1"))'); $sheet->getCell('A9')->setValue('=ISREF(INDIRECT("A1"))');
$sheet->getCell('A10')->setValue('=ISREF(INDIRECT("Invalid Worksheet" & "!" & "A1"))'); $sheet->getCell('A10')->setValue('=ISREF(INDIRECT("Invalid Worksheet" & "!" & "A1"))');
$sheet->getCell('A11')->setValue('=ISREF(ZZZ1)'); $sheet->getCell('A11')->setValue('=ISREF(INDIRECT("Invalid Worksheet" & "!A1"))');
$sheet->getCell('A12')->setValue('=ISREF(CHOOSE(2, A1, B1, C1))'); $sheet->getCell('A12')->setValue('=ISREF(ZZZ1)');
$sheet->getCell('A13')->setValue('=ISREF(CHOOSE(2, A1, B1, C1))');
self::assertTrue($sheet->getCell('A1')->getCalculatedValue()); // Cell Reference self::assertTrue($sheet->getCell('A1')->getCalculatedValue()); // Cell Reference
self::assertTrue($sheet->getCell('A2')->getCalculatedValue()); // Cell Range self::assertTrue($sheet->getCell('A2')->getCalculatedValue()); // Cell Range
@ -36,7 +37,8 @@ class IsRefTest extends AllSetupTeardown
self::assertTrue($sheet->getCell('A8')->getCalculatedValue()); // Indirect to a Cell Reference self::assertTrue($sheet->getCell('A8')->getCalculatedValue()); // Indirect to a Cell Reference
self::assertTrue($sheet->getCell('A9')->getCalculatedValue()); // Indirect to a Worksheet/Cell Reference self::assertTrue($sheet->getCell('A9')->getCalculatedValue()); // Indirect to a Worksheet/Cell Reference
self::assertFalse($sheet->getCell('A10')->getCalculatedValue()); // Indirect to an Invalid Worksheet/Cell Reference self::assertFalse($sheet->getCell('A10')->getCalculatedValue()); // Indirect to an Invalid Worksheet/Cell Reference
self::assertFalse($sheet->getCell('A11')->getCalculatedValue()); // Invalid Cell Reference self::assertFalse($sheet->getCell('A11')->getCalculatedValue()); // Indirect to an Invalid Worksheet/Cell Reference
self::assertTrue($sheet->getCell('A12')->getCalculatedValue()); // returned Cell Reference self::assertFalse($sheet->getCell('A12')->getCalculatedValue()); // Invalid Cell Reference
self::assertTrue($sheet->getCell('A13')->getCalculatedValue()); // returned Cell Reference
} }
} }