diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index a6013e6f..425cf2aa 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -601,6 +601,9 @@ class LookupRef */ public static function INDEX($arrayValues, $rowNum = 0, $columnNum = 0) { + $rowNum = Functions::flattenSingleValue($rowNum); + $columnNum = Functions::flattenSingleValue($columnNum); + if (($rowNum < 0) || ($columnNum < 0)) { return Functions::VALUE(); } diff --git a/tests/data/Calculation/LookupRef/INDEX.php b/tests/data/Calculation/LookupRef/INDEX.php index 3a9c55a2..55206270 100644 --- a/tests/data/Calculation/LookupRef/INDEX.php +++ b/tests/data/Calculation/LookupRef/INDEX.php @@ -73,4 +73,18 @@ return [ 2, 2, ], + [ + 4, // Expected + // Input + [ + '20' => ['R' => 1, 'S' => 3], + '21' => ['R' => 2, 'S' => 4], + ], + [ + '21' => ['R' => 2], + ], + [ + '21' => ['R' => 2], + ], + ], ];