]> source.dussan.org Git - poi.git/commitdiff
[bug-66087] make DStar functions case insensitive
authorPJ Fanning <fanningpj@apache.org>
Wed, 25 May 2022 10:31:07 +0000 (10:31 +0000)
committerPJ Fanning <fanningpj@apache.org>
Wed, 25 May 2022 10:31:07 +0000 (10:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901229 13f79535-47bb-0310-9956-ffa450edef68

poi/src/main/java/org/apache/poi/ss/formula/functions/DStarRunner.java
test-data/spreadsheet/DGet.xls

index 295721b4ddc8894918c7d68d95d32372ce85e807..97f20cebc5c048c49375c65ddeafb32d31628f98 100644 (file)
@@ -17,6 +17,7 @@
 
 package org.apache.poi.ss.formula.functions;
 
+import java.util.Locale;
 import java.util.function.Supplier;
 
 import org.apache.poi.ss.formula.eval.AreaEval;
@@ -30,6 +31,7 @@ import org.apache.poi.ss.formula.eval.StringEval;
 import org.apache.poi.ss.formula.eval.StringValueEval;
 import org.apache.poi.ss.formula.eval.ValueEval;
 import org.apache.poi.ss.util.NumberComparer;
+import org.apache.poi.util.LocaleUtil;
 
 /**
  * This class performs a D* calculation. It takes an {@link IDStarAlgorithm} object and
@@ -316,7 +318,7 @@ public final class DStarRunner implements Function3Arg {
                     return testNumericCondition(value, operator.equal, stringOrNumber);
                 } else { // It's a string.
                     String valueString = value instanceof BlankEval ? "" : OperandResolver.coerceValueToString(value);
-                    return stringOrNumber.equals(valueString);
+                    return stringOrNumber.equalsIgnoreCase(valueString);
                 }
             } else { // It's a text starts-with condition.
                 if(conditionString.isEmpty()) {
@@ -324,7 +326,7 @@ public final class DStarRunner implements Function3Arg {
                 }
                 else {
                     String valueString = value instanceof BlankEval ? "" : OperandResolver.coerceValueToString(value);
-                    return valueString.startsWith(conditionString);
+                    return valueString.toLowerCase(LocaleUtil.getUserLocale()).startsWith(conditionString.toLowerCase(LocaleUtil.getUserLocale()));
                 }
             }
         } else if(condition instanceof NumericValueEval) {
index ddec841904954518cd02030a25c9cc94f12ab4d9..bd66d4e8ecc1ffcc1014a887a5fc4b760f0765d1 100644 (file)
Binary files a/test-data/spreadsheet/DGet.xls and b/test-data/spreadsheet/DGet.xls differ