]> source.dussan.org Git - poi.git/commitdiff
case insensitive r1c1 refs
authorPJ Fanning <fanningpj@apache.org>
Mon, 21 Feb 2022 13:17:13 +0000 (13:17 +0000)
committerPJ Fanning <fanningpj@apache.org>
Mon, 21 Feb 2022 13:17:13 +0000 (13:17 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1898274 13f79535-47bb-0310-9956-ffa450edef68

poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
poi/src/test/java/org/apache/poi/ss/formula/functions/TestIndirect.java

index 5b4799f35a2ae8152d4d15ff9df108327a81a84c..1901ec7e4f377d15bd0d3d975c096ecf704335e8 100644 (file)
@@ -42,6 +42,9 @@ import org.apache.poi.ss.formula.ptg.Ref3DPtg;
 import org.apache.poi.ss.formula.ptg.Ref3DPxg;
 import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.ss.util.CellReference.NameType;
+import org.apache.poi.util.LocaleUtil;
+
+import java.util.Locale;
 
 /**
  * Contains all the contextual information required to evaluate an operation
@@ -533,8 +536,9 @@ public final class OperationEvaluationContext {
     }
 
     public static CellReference applyR1C1Reference(CellReference anchorReference, String relativeReference) {
-        int rpos = relativeReference.indexOf('R');
-        int cpos = relativeReference.indexOf('C');
+        String upRef = relativeReference.toUpperCase(LocaleUtil.getUserLocale());
+        int rpos = upRef.indexOf('R');
+        int cpos = upRef.indexOf('C');
         if (rpos >= 0 && cpos > rpos) {
             String rval = relativeReference.substring(rpos + 1, cpos).trim();
             String cval = relativeReference.substring(cpos + 1).trim();
index c8a58803e6a8d30bfac6b9927c3bcaff780da925..18e31d2c6ace791c77399db776848357bea1de32 100644 (file)
@@ -168,10 +168,13 @@ final class TestIndirect {
 
             // non-error cases
             confirm(feA, c, "INDIRECT(\"R2C3\", FALSE)", 23);
+            confirm(feA, c, "INDIRECT(\"r2c3\", FALSE)", 23);
             confirm(feA, c, "INDIRECT(\"R[-4]C[0]\", FALSE)", 23);
             confirm(feA, c, "INDIRECT(\"R[-4]C\", FALSE)", 23);
             confirm(feA, c, "INDIRECT(\"R1C1:R1C7\", FALSE)", 13); // de-reference area ref (note formula is in C4)
+            confirm(feA, c, "INDIRECT(\"r1c1:r1c7\", FALSE)", 13); // de-reference area ref (note formula is in C4)
             confirm(feA, c, "SUM(INDIRECT(\"Sheet2!R1C2:R3C3\", FALSE))", 351); // area ref
+            confirm(feA, c, "SUM(INDIRECT(\"Sheet2!r1c2:r3c3\", FALSE))", 351); // area ref
             confirm(feA, c, "SUM(INDIRECT(\"Sheet2! R1C2 : R3C3 \", FALSE))", 351); // spaces in area ref
 
             //scenarios yet to support