diff options
Diffstat (limited to 'src/java')
-rw-r--r-- | src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java b/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java index 87018e6abe..d1407c064b 100644 --- a/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java +++ b/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java @@ -37,6 +37,7 @@ import org.apache.poi.ss.util.CellReference.NameType; * For POI internal use only * * @author Josh Micich + * @author Cédric Walter */ public final class OperationEvaluationContext { public static final FreeRefFunction UDF = UserDefinedFunction.instance; @@ -83,13 +84,13 @@ public final class OperationEvaluationContext { } else { // look up sheet by name from external workbook String workbookName = externalSheet.getWorkbookName(); - try {
- targetEvaluator = _bookEvaluator.getOtherWorkbookEvaluator(workbookName);
- } catch (WorkbookNotFoundException e) {
- throw new RuntimeException(e.getMessage(), e);
- }
- otherSheetIndex = targetEvaluator.getSheetIndex(externalSheet.getSheetName());
- if (otherSheetIndex < 0) {
+ try { + targetEvaluator = _bookEvaluator.getOtherWorkbookEvaluator(workbookName); + } catch (WorkbookNotFoundException e) { + throw new RuntimeException(e.getMessage(), e); + } + otherSheetIndex = targetEvaluator.getSheetIndex(externalSheet.getSheetName()); + if (otherSheetIndex < 0) { throw new RuntimeException("Invalid sheet name '" + externalSheet.getSheetName() + "' in bool '" + workbookName + "'."); } @@ -195,16 +196,32 @@ public final class OperationEvaluationContext { int firstRow, firstCol, lastRow, lastCol; switch (part1refType) { case COLUMN: - firstRow =0; - lastRow = ssVersion.getLastRowIndex(); - firstCol = parseColRef(refStrPart1); - lastCol = parseColRef(refStrPart2); - break; + firstRow =0; + if (part2refType.equals(NameType.COLUMN)) + { + lastRow = ssVersion.getLastRowIndex(); + firstCol = parseRowRef(refStrPart1); + lastCol = parseRowRef(refStrPart2); + } + else { + lastRow = ssVersion.getLastRowIndex(); + firstCol = parseColRef(refStrPart1); + lastCol = parseColRef(refStrPart2); + } + break; case ROW: - firstCol = 0; - lastCol = ssVersion.getLastColumnIndex(); - firstRow = parseRowRef(refStrPart1); - lastRow = parseRowRef(refStrPart2); + // support of cell range in the form of integer:integer + firstCol = 0; + if (part2refType.equals(NameType.ROW)) + { + firstRow = parseColRef(refStrPart1); + lastRow = parseColRef(refStrPart2); + lastCol = ssVersion.getLastColumnIndex(); + } else { + lastCol = ssVersion.getLastColumnIndex(); + firstRow = parseRowRef(refStrPart1); + lastRow = parseRowRef(refStrPart2); + } break; case CELL: CellReference cr; |