summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2014-11-04 22:00:09 +0000
committerNick Burch <nick@apache.org>2014-11-04 22:00:09 +0000
commitbc644862262126a3fb30e4e8a4dbddfb63075549 (patch)
treeb5f0cbb94b7ab534421ba7a9a4a51c44fe6cddbd /src
parentca59b7c8afa6ee0a724a779233d8f7a7699845ee (diff)
downloadpoi-bc644862262126a3fb30e4e8a4dbddfb63075549.tar.gz
poi-bc644862262126a3fb30e4e8a4dbddfb63075549.zip
Some more XSSF testing for #57184
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1636750 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java8
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java28
2 files changed, 27 insertions, 9 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
index 7164534d3b..119f77507e 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
@@ -1705,16 +1705,16 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
}
/**
- * 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");
}
/**
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
index 508844fdd1..c2a7597d38 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
@@ -167,12 +167,32 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
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 TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
} 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);