INDEX(): fix getting row and col numbers from references (#239)

Allow to use cell references as row and column in function INDEX(). Eg:

```
=INDEX(A1:B5, A9)
```
This commit is contained in:
Maxim 2017-10-06 08:01:20 +03:00 committed by Adrien Crivelli
parent 088a76737e
commit 4b4bac53aa
2 changed files with 17 additions and 0 deletions

View File

@ -601,6 +601,9 @@ class LookupRef
*/ */
public static function INDEX($arrayValues, $rowNum = 0, $columnNum = 0) public static function INDEX($arrayValues, $rowNum = 0, $columnNum = 0)
{ {
$rowNum = Functions::flattenSingleValue($rowNum);
$columnNum = Functions::flattenSingleValue($columnNum);
if (($rowNum < 0) || ($columnNum < 0)) { if (($rowNum < 0) || ($columnNum < 0)) {
return Functions::VALUE(); return Functions::VALUE();
} }

View File

@ -73,4 +73,18 @@ return [
2, 2,
2, 2,
], ],
[
4, // Expected
// Input
[
'20' => ['R' => 1, 'S' => 3],
'21' => ['R' => 2, 'S' => 4],
],
[
'21' => ['R' => 2],
],
[
'21' => ['R' => 2],
],
],
]; ];