diff options
author | PJ Fanning <fanningpj@apache.org> | 2022-02-21 13:17:13 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2022-02-21 13:17:13 +0000 |
commit | 9e455b47dccf3560681148c7728eb441bb7129a9 (patch) | |
tree | d2d5bf30a4c7d0813abb76758eaf12c3939891d2 | |
parent | ec2f0efd2881d162fc6f3406e5ff3f674d19ca58 (diff) | |
download | poi-9e455b47dccf3560681148c7728eb441bb7129a9.tar.gz poi-9e455b47dccf3560681148c7728eb441bb7129a9.zip |
case insensitive r1c1 refs
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1898274 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java | 8 | ||||
-rw-r--r-- | poi/src/test/java/org/apache/poi/ss/formula/functions/TestIndirect.java | 3 |
2 files changed, 9 insertions, 2 deletions
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 |