Skip to content

Commit 3c57d9e

Browse files
author
Mark Baker
authored
Fix for issue #2614 (#2615)
* Fix for issue #2614 * Unit test (in ISREF() tests) that covers issue #2614
1 parent c9f948b commit 3c57d9e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/PhpSpreadsheet/Calculation/Calculation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3895,12 +3895,12 @@ private function internalParseFormula($formula, ?Cell $cell = null)
38953895
// so we store the parent worksheet so that we can re-attach it when necessary
38963896
$pCellParent = ($cell !== null) ? $cell->getWorksheet() : null;
38973897

3898-
$regexpMatchString = '/^(' . self::CALCULATION_REGEXP_FUNCTION .
3898+
$regexpMatchString = '/^(' . self::CALCULATION_REGEXP_STRING .
3899+
'|' . self::CALCULATION_REGEXP_FUNCTION .
38993900
'|' . self::CALCULATION_REGEXP_CELLREF .
39003901
'|' . self::CALCULATION_REGEXP_COLUMN_RANGE .
39013902
'|' . self::CALCULATION_REGEXP_ROW_RANGE .
39023903
'|' . self::CALCULATION_REGEXP_NUMBER .
3903-
'|' . self::CALCULATION_REGEXP_STRING .
39043904
'|' . self::CALCULATION_REGEXP_OPENBRACE .
39053905
'|' . self::CALCULATION_REGEXP_DEFINEDNAME .
39063906
'|' . self::CALCULATION_REGEXP_ERROR .

tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsRefTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ public function testIsRef(): void
2323
$sheet->getCell('A8')->setValue('=ISREF(INDIRECT("' . $sheet->getTitle() . '" & "!" & "A1"))');
2424
$sheet->getCell('A9')->setValue('=ISREF(INDIRECT("A1"))');
2525
$sheet->getCell('A10')->setValue('=ISREF(INDIRECT("Invalid Worksheet" & "!" & "A1"))');
26-
$sheet->getCell('A11')->setValue('=ISREF(ZZZ1)');
27-
$sheet->getCell('A12')->setValue('=ISREF(CHOOSE(2, A1, B1, C1))');
26+
$sheet->getCell('A11')->setValue('=ISREF(INDIRECT("Invalid Worksheet" & "!A1"))');
27+
$sheet->getCell('A12')->setValue('=ISREF(ZZZ1)');
28+
$sheet->getCell('A13')->setValue('=ISREF(CHOOSE(2, A1, B1, C1))');
2829

2930
self::assertTrue($sheet->getCell('A1')->getCalculatedValue()); // Cell Reference
3031
self::assertTrue($sheet->getCell('A2')->getCalculatedValue()); // Cell Range
@@ -36,7 +37,8 @@ public function testIsRef(): void
3637
self::assertTrue($sheet->getCell('A8')->getCalculatedValue()); // Indirect to a Cell Reference
3738
self::assertTrue($sheet->getCell('A9')->getCalculatedValue()); // Indirect to a Worksheet/Cell Reference
3839
self::assertFalse($sheet->getCell('A10')->getCalculatedValue()); // Indirect to an Invalid Worksheet/Cell Reference
39-
self::assertFalse($sheet->getCell('A11')->getCalculatedValue()); // Invalid Cell Reference
40-
self::assertTrue($sheet->getCell('A12')->getCalculatedValue()); // returned Cell Reference
40+
self::assertFalse($sheet->getCell('A11')->getCalculatedValue()); // Indirect to an Invalid Worksheet/Cell Reference
41+
self::assertFalse($sheet->getCell('A12')->getCalculatedValue()); // Invalid Cell Reference
42+
self::assertTrue($sheet->getCell('A13')->getCalculatedValue()); // returned Cell Reference
4143
}
4244
}

0 commit comments

Comments
 (0)