You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2014/11/04 23:00:09 UTC

svn commit: r1636750 - in /poi/trunk/src/ooxml: java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java

Author: nick
Date: Tue Nov  4 22:00:09 2014
New Revision: 1636750

URL: http://svn.apache.org/r1636750
Log:
Some more XSSF testing for #57184

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=1636750&r1=1636749&r2=1636750&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Tue Nov  4 22:00:09 2014
@@ -1705,16 +1705,16 @@ public class XSSFWorkbook extends POIXML
     }
 
     /**
-     * Adds the LinkTable records required to allow formulas referencing
-     *  the specified external workbook to be added to this one. Allows
+     * Adds the External Link Table part and relations required to allow formulas 
+     *  referencing the specified external workbook to be added to this one. Allows
      *  formulas such as "[MyOtherWorkbook.xlsx]Sheet3!$A$5" to be added to the 
-     *  file, for workbooks not already referenced.
+     *  file, for workbooks not already linked / referenced.
      *
      * @param name The name the workbook will be referenced as in formulas
      * @param workbook The open workbook to fetch the link required information from
      */
     public int linkExternalWorkbook(String name, Workbook workbook) {
-        throw new RuntimeException("NotImplemented");
+        throw new RuntimeException("Not Implemented - see bug #57184");
     }
 
 	/**

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java?rev=1636750&r1=1636749&r2=1636750&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java Tue Nov  4 22:00:09 2014
@@ -167,12 +167,32 @@ public final class TestXSSFFormulaEvalua
         assertEquals("\"Test A1\"", evaluator.evaluate(cXSL_sNR).formatAsString());
         assertEquals("142.0",   evaluator.evaluate(cXSL_gNR).formatAsString());
         
-/**        
+        
+        // Add another formula referencing these workbooks
+        Cell cXSL_cell2 = rXSL.createCell(40);
+        cXSL_cell2.setCellFormula("[56737.xls]Uses!$C$1");
+        // TODO Shouldn't it become [2] like the others?
+        assertEquals("[56737.xls]Uses!$C$1", cXSL_cell2.getCellFormula());
+        assertEquals("\"Hello!\"",  evaluator.evaluate(cXSL_cell2).formatAsString());
+        
+        
         // Now add a formula that refers to yet another (different) workbook
+        // Won't work without the workbook being linked
         Cell cXSLX_nw_cell = rXSLX.createCell(42);
-        cXSLX_nw_cell.setCellFormula("[alt.xlsx]Sheet1!$A$1");
+        try {
+            cXSLX_nw_cell.setCellFormula("[alt.xlsx]Sheet1!$A$1");
+            fail("New workbook not linked, shouldn't be able to add");
+        } catch (Exception e) {}
         
-        // Check it - TODO Is this correct? Or should it become [2]Sheet1!$A$1 ?
+        // Link and re-try
+        Workbook alt = new XSSFWorkbook();
+        alt.createSheet().createRow(0).createCell(0).setCellValue("In another workbook");
+        // TODO Implement the rest of this, see bug #57184
+/*
+        wb.linkExternalWorkbook("alt.xlsx", alt);
+                
+        cXSLX_nw_cell.setCellFormula("[alt.xlsx]Sheet1!$A$1");
+        // Check it - TODO Is this correct? Or should it become [3]Sheet1!$A$1 ?
         assertEquals("[alt.xlsx]Sheet1!$A$1", cXSLX_nw_cell.getCellFormula());
         
         // Evaluate it, without a link to that workbook
@@ -182,8 +202,6 @@ public final class TestXSSFFormulaEvalua
         } catch(Exception e) {}
         
         // Add a link, check it does
-        Workbook alt = new XSSFWorkbook();
-        alt.createSheet().createRow(0).createCell(0).setCellValue("In another workbook");
         evaluators.put("alt.xlsx", alt.getCreationHelper().createFormulaEvaluator());
         evaluator.setupReferencedWorkbooks(evaluators);
         



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