diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 0f8c1b97..2cf57915 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -3895,12 +3895,12 @@ class Calculation // so we store the parent worksheet so that we can re-attach it when necessary $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_COLUMN_RANGE . '|' . self::CALCULATION_REGEXP_ROW_RANGE . '|' . self::CALCULATION_REGEXP_NUMBER . - '|' . self::CALCULATION_REGEXP_STRING . '|' . self::CALCULATION_REGEXP_OPENBRACE . '|' . self::CALCULATION_REGEXP_DEFINEDNAME . '|' . self::CALCULATION_REGEXP_ERROR . diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsRefTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsRefTest.php index 04d71959..d723cc08 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsRefTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsRefTest.php @@ -23,8 +23,9 @@ class IsRefTest extends AllSetupTeardown $sheet->getCell('A8')->setValue('=ISREF(INDIRECT("' . $sheet->getTitle() . '" & "!" & "A1"))'); $sheet->getCell('A9')->setValue('=ISREF(INDIRECT("A1"))'); $sheet->getCell('A10')->setValue('=ISREF(INDIRECT("Invalid Worksheet" & "!" & "A1"))'); - $sheet->getCell('A11')->setValue('=ISREF(ZZZ1)'); - $sheet->getCell('A12')->setValue('=ISREF(CHOOSE(2, A1, B1, C1))'); + $sheet->getCell('A11')->setValue('=ISREF(INDIRECT("Invalid Worksheet" & "!A1"))'); + $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('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('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('A11')->getCalculatedValue()); // Invalid Cell Reference - self::assertTrue($sheet->getCell('A12')->getCalculatedValue()); // returned Cell Reference + self::assertFalse($sheet->getCell('A11')->getCalculatedValue()); // Indirect to an Invalid Worksheet/Cell Reference + self::assertFalse($sheet->getCell('A12')->getCalculatedValue()); // Invalid Cell Reference + self::assertTrue($sheet->getCell('A13')->getCalculatedValue()); // returned Cell Reference } }