aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases
diff options
context:
space:
mode:
authorDavid North <dnorth@apache.org>2015-08-19 10:10:08 +0000
committerDavid North <dnorth@apache.org>2015-08-19 10:10:08 +0000
commit14be991668e4ae8f05b349ae3b01c40627ce2e21 (patch)
tree054364a563b158a9d9fb866aa138928c754f6f8a /src/ooxml/testcases
parentc275ebb44c3973880449e606e8df57352a34a116 (diff)
downloadpoi-14be991668e4ae8f05b349ae3b01c40627ce2e21.tar.gz
poi-14be991668e4ae8f05b349ae3b01c40627ce2e21.zip
Make intersection formulae work in XSSF. Patch from Matt Hillsdon plus additional tests.
https://bz.apache.org/bugzilla/show_bug.cgi?id=52111 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1696549 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases')
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
index 1409d42274..00aa4b2f75 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
@@ -2501,4 +2501,30 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57181.xlsm");
assertEquals(9, wb.getNumberOfSheets());
}
+
+ @Test
+ public void bug52111() throws Exception {
+ Workbook wb = XSSFTestDataSamples.openSampleWorkbook("Intersection-52111-xssf.xlsx");
+ Sheet s = wb.getSheetAt(0);
+ assertFormula(wb, s.getRow(2).getCell(0), "(C2:D3 D3:E4)", "4.0");
+ assertFormula(wb, s.getRow(6).getCell(0), "Tabelle2!E:E Tabelle2!11:11", "5.0");
+ assertFormula(wb, s.getRow(8).getCell(0), "Tabelle2!E:F Tabelle2!11:12", null);
+ }
+
+ private void assertFormula(Workbook wb, Cell intF, String expectedFormula, String expectedResultOrNull) {
+ assertEquals(Cell.CELL_TYPE_FORMULA, intF.getCellType());
+ if (null == expectedResultOrNull) {
+ assertEquals(Cell.CELL_TYPE_ERROR, intF.getCachedFormulaResultType());
+ expectedResultOrNull = "#VALUE!";
+ }
+ else {
+ assertEquals(Cell.CELL_TYPE_NUMERIC, intF.getCachedFormulaResultType());
+ }
+
+ assertEquals(expectedFormula, intF.getCellFormula());
+
+ // Check we can evaluate it correctly
+ FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
+ assertEquals(expectedResultOrNull, eval.evaluate(intF).formatAsString());
+ }
}