From a093a468d191239dfea5b4aa450235b93ef2dea8 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Thu, 26 Oct 2017 23:02:53 +0900 Subject: [PATCH] HLOOKUP check on the count of the rows, not columns We must check on the count of the rows (`row_index_num` and not `col_index_num` as in VLOOKUP) and not on the columns. https://support.office.com/en-us/article/HLOOKUP-function-a3034eec-b719-4ba3-bb65-e1ad662ed95f Fixes https://github.com/PHPOffice/PHPExcel/issues/1339 --- src/PhpSpreadsheet/Calculation/LookupRef.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index 425cf2aa..93f336ee 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -789,7 +789,7 @@ class LookupRef } $f = array_keys($lookup_array); $firstRow = array_pop($f); - if ((!is_array($lookup_array[$firstRow])) || ($index_number - 1 > count($lookup_array[$firstRow]))) { + if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array))) { return Functions::REF(); } $columnKeys = array_keys($lookup_array[$firstRow]);