From 3e41ddf7a4f78e9575c3081003bca5e6a2c0359f Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 4 Jul 2019 09:07:22 +0200 Subject: [PATCH] Fix #1055 : Make hlookup require ordered list only if asking for not exact match --- src/PhpSpreadsheet/Calculation/LookupRef.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index e6b0f3203f..f2d22c0023 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -794,8 +794,10 @@ public static function HLOOKUP($lookup_value, $lookup_array, $index_number, $not $lookupLower = StringHelper::strToLower($lookup_value); $rowDataLower = StringHelper::strToLower($rowData); - if (($bothNumeric && $rowData > $lookup_value) || - ($bothNotNumeric && $rowDataLower > $lookupLower)) { + if ($not_exact_match && ( + ($bothNumeric && $rowData > $lookup_value) || + ($bothNotNumeric && $rowDataLower > $lookupLower) + )) { break; }