From: PJ Fanning Date: Mon, 21 Feb 2022 13:17:13 +0000 (+0000) Subject: case insensitive r1c1 refs X-Git-Tag: REL_5_2_1~46 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9e455b47dccf3560681148c7728eb441bb7129a9;p=poi.git case insensitive r1c1 refs git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1898274 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java b/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java index 5b4799f35a..1901ec7e4f 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java @@ -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(); diff --git a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestIndirect.java b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestIndirect.java index c8a58803e6..18e31d2c6a 100644 --- a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestIndirect.java +++ b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestIndirect.java @@ -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