]> source.dussan.org Git - poi.git/commitdiff
Unit test to show that bug #52111 (intersect formulas) was already solved
authorNick Burch <nick@apache.org>
Sat, 26 Jul 2014 22:39:16 +0000 (22:39 +0000)
committerNick Burch <nick@apache.org>
Sat, 26 Jul 2014 22:39:16 +0000 (22:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1613737 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
test-data/spreadsheet/Intersection-52111.xls [new file with mode: 0644]

index c2b4c67ba2fe6c6f89df715c7495cca9d262d6a7..de12602e40fd3cdb9bdd4dfea1cb1272930cbc7a 100644 (file)
@@ -2702,4 +2702,24 @@ public final class TestBugs extends BaseTestBugzillaIssues {
         // Optimise
         HSSFOptimiser.optimiseCellStyles(workbook);
     }
+    
+    /**
+     * Intersection formula ranges, eg =(C2:D3 D3:E4)
+     */
+    @Test
+    public void bug52111() throws Exception {
+        Workbook wb = openSample("Intersection-52111.xls");
+        Sheet s = wb.getSheetAt(0);
+
+        // Check we can read it correctly
+        Cell intF = s.getRow(2).getCell(0);
+        assertEquals(Cell.CELL_TYPE_FORMULA, intF.getCellType());
+        assertEquals(Cell.CELL_TYPE_NUMERIC, intF.getCachedFormulaResultType());
+        
+        assertEquals("(C2:D3 D3:E4)", intF.getCellFormula());
+        
+        // Check we can evaluate it correctly
+        FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
+        assertEquals("4.0", eval.evaluate(intF).formatAsString());
+    }
 }
diff --git a/test-data/spreadsheet/Intersection-52111.xls b/test-data/spreadsheet/Intersection-52111.xls
new file mode 100644 (file)
index 0000000..835130e
Binary files /dev/null and b/test-data/spreadsheet/Intersection-52111.xls differ