diff options
author | PJ Fanning <fanningpj@apache.org> | 2022-02-21 13:37:35 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2022-02-21 13:37:35 +0000 |
commit | c0dc2e51ce215db532e37c756044fa562f71d742 (patch) | |
tree | fb18a312f448697ab7d880cf8cae1d406bc56b68 /poi | |
parent | 46e69ca69f35c337b75a4827516dfd22a78d40af (diff) | |
download | poi-c0dc2e51ce215db532e37c756044fa562f71d742.tar.gz poi-c0dc2e51ce215db532e37c756044fa562f71d742.zip |
fix issue
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1898276 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r-- | poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java | 23 |
1 files changed, 21 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 1901ec7e4f..bdadbfad42 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 @@ -223,7 +223,7 @@ public final class OperationEvaluationContext { 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 OperationEvaluationContext { } 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 OperationEvaluationContext { 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; + } + } + } } |