You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2022/02/21 13:37:35 UTC

svn commit: r1898276 - /poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java

Author: fanningpj
Date: Mon Feb 21 13:37:35 2022
New Revision: 1898276

URL: http://svn.apache.org/viewvc?rev=1898276&view=rev
Log:
fix issue

Modified:
    poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java

Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java?rev=1898276&r1=1898275&r2=1898276&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java Mon Feb 21 13:37:35 2022
@@ -223,7 +223,7 @@ public final class OperationEvaluationCo
 
         SpreadsheetVersion ssVersion = _workbook.getSpreadsheetVersion();
 
-        NameType part1refType = isA1Style ? classifyCellReference(refStrPart1, ssVersion) : NameType.CELL;
+        NameType part1refType = isA1Style ? classifyCellReference(refStrPart1, ssVersion) : getR1C1CellType(refStrPart1);
         switch (part1refType) {
             case BAD_CELL_OR_NAMED_RANGE:
                 return ErrorEval.REF_INVALID;
@@ -255,7 +255,7 @@ public final class OperationEvaluationCo
             }
             throw new IllegalStateException("Unexpected reference classification of '" + refStrPart1 + "'.");
         }
-        NameType part2refType = isA1Style ? classifyCellReference(refStrPart1, ssVersion) : NameType.CELL;
+        NameType part2refType = isA1Style ? classifyCellReference(refStrPart2, ssVersion) : getR1C1CellType(refStrPart2);
         switch (part2refType) {
             case BAD_CELL_OR_NAMED_RANGE:
                 return ErrorEval.REF_INVALID;
@@ -573,4 +573,23 @@ public final class OperationEvaluationCo
             throw new IllegalArgumentException(relativeReference + " is not a valid R1C1 reference");
         }
     }
+
+    private static NameType getR1C1CellType(String str) {
+        String upRef = str.toUpperCase(LocaleUtil.getUserLocale());
+        int rpos = upRef.indexOf('R');
+        int cpos = upRef.indexOf('C');
+        if (rpos != -1) {
+            if (cpos == -1) {
+                return NameType.ROW;
+            } else {
+                return NameType.CELL;
+            }
+        } else {
+            if (cpos == -1) {
+                return NameType.BAD_CELL_OR_NAMED_RANGE;
+            } else {
+                return NameType.COLUMN;
+            }
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org