]> source.dussan.org Git - poi.git/commitdiff
Allow XSSF to evaluate multi-sheet references too, for #55906
authorNick Burch <nick@apache.org>
Fri, 25 Jul 2014 15:55:49 +0000 (15:55 +0000)
committerNick Burch <nick@apache.org>
Fri, 25 Jul 2014 15:55:49 +0000 (15:55 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1613455 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java

index 6dba12aba853cf3603f84a0b6a3f980f9b0163ed..ce918926caa726b89ea7ef41973f3dc306749784 100644 (file)
@@ -79,8 +79,8 @@ public final class OperationEvaluationContext {
        SheetRangeEvaluator createExternSheetRefEvaluator(ExternSheetReferenceToken ptg) {
                return createExternSheetRefEvaluator(ptg.getExternSheetIndex());
        }
-       SheetRangeEvaluator createExternSheetRefEvaluator(String sheetName, int externalWorkbookNumber) {
-        ExternalSheet externalSheet = _workbook.getExternalSheet(sheetName, null, externalWorkbookNumber);
+       SheetRangeEvaluator createExternSheetRefEvaluator(String firstSheetName, String lastSheetName, int externalWorkbookNumber) {
+        ExternalSheet externalSheet = _workbook.getExternalSheet(firstSheetName, lastSheetName, externalWorkbookNumber);
         return createExternSheetRefEvaluator(externalSheet);
     }
        SheetRangeEvaluator createExternSheetRefEvaluator(int externSheetIndex) {
@@ -306,7 +306,8 @@ public final class OperationEvaluationContext {
                return new LazyRefEval(rptg.getRow(), rptg.getColumn(), sre);
        }
     public ValueEval getRef3DEval(Ref3DPxg rptg) {
-        SheetRangeEvaluator sre = createExternSheetRefEvaluator(rptg.getSheetName(), rptg.getExternalWorkbookNumber());
+        SheetRangeEvaluator sre = createExternSheetRefEvaluator(
+                rptg.getSheetName(), rptg.getLastSheetName(), rptg.getExternalWorkbookNumber());
         return new LazyRefEval(rptg.getRow(), rptg.getColumn(), sre);
     }
     
@@ -321,7 +322,8 @@ public final class OperationEvaluationContext {
                 aptg.getLastRow(), aptg.getLastColumn(), sre);
     }
     public ValueEval getArea3DEval(Area3DPxg aptg) {
-        SheetRangeEvaluator sre = createExternSheetRefEvaluator(aptg.getSheetName(), aptg.getExternalWorkbookNumber());
+        SheetRangeEvaluator sre = createExternSheetRefEvaluator(
+                aptg.getSheetName(), aptg.getLastSheetName(), aptg.getExternalWorkbookNumber());
         return new LazyAreaEval(aptg.getFirstRow(), aptg.getFirstColumn(),
                 aptg.getLastRow(), aptg.getLastColumn(), sre);
     }
index 9542c92691d19375b2a9a37085def068bbd2d539..09c45f0404227dff8d317265dd14b459f9662476 100644 (file)
@@ -184,10 +184,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
      *  Sheets 1 through Sheet 3).
      * This test, based on common test files for HSSF and XSSF, checks
      *  that we can correctly evaluate these
-     *  
-     * TODO Fix this to pass for XSSF too, currently only passes for HSSF...
      */
-    public void DISABLEDtestMultiSheetReferencesHSSFandXSSF() throws Exception {
+    public void testMultiSheetReferencesHSSFandXSSF() throws Exception {
         Workbook[] wbs = new Workbook[] {
                 HSSFTestDataSamples.openSampleWorkbook("55906-MultiSheetRefs.xls"),
                 XSSFTestDataSamples.openSampleWorkbook("55906-MultiSheetRefs.xlsx")