Skip to content

Commit a093a46

Browse files
committed
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 PHPOffice/PHPExcel#1339
1 parent 25ff914 commit a093a46

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/PhpSpreadsheet/Calculation/LookupRef.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ public static function HLOOKUP($lookup_value, $lookup_array, $index_number, $not
789789
}
790790
$f = array_keys($lookup_array);
791791
$firstRow = array_pop($f);
792-
if ((!is_array($lookup_array[$firstRow])) || ($index_number - 1 > count($lookup_array[$firstRow]))) {
792+
if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array))) {
793793
return Functions::REF();
794794
}
795795
$columnKeys = array_keys($lookup_array[$firstRow]);

0 commit comments

Comments
 (0)