]> source.dussan.org Git - poi.git/commitdiff
refactor LookupUtils
authorPJ Fanning <fanningpj@apache.org>
Fri, 3 Dec 2021 12:08:50 +0000 (12:08 +0000)
committerPJ Fanning <fanningpj@apache.org>
Fri, 3 Dec 2021 12:08:50 +0000 (12:08 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895546 13f79535-47bb-0310-9956-ffa450edef68

poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java

index be113ec4bd9d64cebdd3cd651ed141abf946c33f..7ba7b18a1157317f9156854a154c319d538c6cce 100644 (file)
@@ -623,7 +623,7 @@ public final class LookupUtils {
     }
 
     public static int xlookupIndexOfValue(ValueEval lookupValue, ValueVector vector, MatchMode matchMode, SearchMode searchMode) throws EvaluationException {
-        LookupValueComparer lookupComparer = createTolerantLookupComparer(lookupValue, true, true);
+        LookupValueComparer lookupComparer = createTolerantLookupComparer(lookupValue, matchMode != MatchMode.WildcardMatch, true);
         int result;
         if (searchMode == SearchMode.BinarySearchForward || searchMode == SearchMode.BinarySearchBackward) {
             result = binarySearchIndexOfValue(lookupComparer, vector, matchMode);
@@ -757,7 +757,11 @@ public final class LookupUtils {
                     }
                     break;
             }
-            bsi.narrowSearch(i, result.isLessThan());
+            if (result.isTypeMismatch()) {
+                handleMidValueTypeMismatch(lookupComparer, vector, bsi, i);
+            } else {
+                bsi.narrowSearch(i, result.isLessThan());
+            }
         }
     }