]> source.dussan.org Git - poi.git/commitdiff
continue cleanup of bugzilla, added unit test for #27394, #27364, #300#30070 and...
authorYegor Kozlov <yegor@apache.org>
Mon, 29 Dec 2008 16:51:30 +0000 (16:51 +0000)
committerYegor Kozlov <yegor@apache.org>
Mon, 29 Dec 2008 16:51:30 +0000 (16:51 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@729943 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/hssf/data/27364.xls [new file with mode: 0755]
src/testcases/org/apache/poi/hssf/data/27394.xls [new file with mode: 0755]
src/testcases/org/apache/poi/hssf/data/30070.xls [new file with mode: 0755]
src/testcases/org/apache/poi/hssf/data/31661.xls [new file with mode: 0755]
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

diff --git a/src/testcases/org/apache/poi/hssf/data/27364.xls b/src/testcases/org/apache/poi/hssf/data/27364.xls
new file mode 100755 (executable)
index 0000000..73aa3fa
Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/27364.xls differ
diff --git a/src/testcases/org/apache/poi/hssf/data/27394.xls b/src/testcases/org/apache/poi/hssf/data/27394.xls
new file mode 100755 (executable)
index 0000000..e9ba1cc
Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/27394.xls differ
diff --git a/src/testcases/org/apache/poi/hssf/data/30070.xls b/src/testcases/org/apache/poi/hssf/data/30070.xls
new file mode 100755 (executable)
index 0000000..5ae6685
Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/30070.xls differ
diff --git a/src/testcases/org/apache/poi/hssf/data/31661.xls b/src/testcases/org/apache/poi/hssf/data/31661.xls
new file mode 100755 (executable)
index 0000000..79050b4
Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/31661.xls differ
index 1766199e45c8fb2927a80212626ab0e1d3195806..040d3cfae86543e44fd501f237b750915dce0b36 100644 (file)
 
 package org.apache.poi.hssf.usermodel;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
+import java.io.*;
 import java.util.Iterator;
 import java.util.List;
 
@@ -1575,4 +1572,74 @@ public final class TestBugs extends TestCase {
                assertEquals(len, c.getRichStringCellValue().length());
        }
     }
+
+    /**
+     * In POI-2.5 user reported exception when parsing a name with a custom VBA function:
+     *  =MY_VBA_FUNCTION("lskdjflsk")
+     */
+    public void test30070() {
+        HSSFWorkbook wb = openSample("30070.xls"); //contains custom VBA function 'Commission'
+        HSSFSheet sh = wb.getSheetAt(0);
+        HSSFCell cell = sh.getRow(0).getCell(1);
+
+        //B1 uses VBA in the formula
+        assertEquals("Commission(A1)", cell.getCellFormula());
+
+        //name sales_1 refers to Commission(Sheet0!$A$1)
+        int idx = wb.getNameIndex("sales_1");
+        assertTrue(idx != -1);
+
+        HSSFName name = wb.getNameAt(idx);
+        assertEquals("Commission(Sheet0!$A$1)", name.getRefersToFormula());
+
+    }
+
+    /**
+     * The link formulas which is referring to other books cannot be taken (the bug existed prior to POI-3.2)
+     * Expected:
+     *
+     * [link_sub.xls]Sheet1!$A$1
+     * [link_sub.xls]Sheet1!$A$2
+     * [link_sub.xls]Sheet1!$A$3
+     *
+     * POI-3.1 output:
+     *
+     * Sheet1!$A$1
+     * Sheet1!$A$2
+     * Sheet1!$A$3
+     *
+     */
+    public void test27364() {
+        HSSFWorkbook wb = openSample("27364.xls");
+        HSSFSheet sheet = wb.getSheetAt(0);
+
+        assertEquals("[link_sub.xls]Sheet1!$A$1", sheet.getRow(0).getCell(0).getCellFormula());
+        assertEquals("[link_sub.xls]Sheet1!$A$2", sheet.getRow(1).getCell(0).getCellFormula());
+        assertEquals("[link_sub.xls]Sheet1!$A$3", sheet.getRow(2).getCell(0).getCellFormula());
+    }
+
+    /**
+     * Similar to bug#27364:
+     * HSSFCell.getCellFormula() fails with references to external workbooks
+     */
+    public void test31661() {
+        HSSFWorkbook wb = openSample("31661.xls");
+        HSSFSheet sheet = wb.getSheetAt(0);
+        HSSFCell cell = sheet.getRow(11).getCell(10); //K11
+        assertEquals("+'[GM Budget.xls]8085.4450'!$B$2", cell.getCellFormula());
+    }
+
+    /**
+     * Incorrect handling of non-ISO 8859-1 characters in Windows ANSII Code Page 1252
+     */
+    public void test27394() {
+        HSSFWorkbook wb = openSample("27394.xls");
+        assertEquals("\u0161\u017E", wb.getSheetName(0));
+        assertEquals("\u0161\u017E\u010D\u0148\u0159", wb.getSheetName(1));
+        HSSFSheet sheet = wb.getSheetAt(0);
+
+        assertEquals("\u0161\u017E", sheet.getRow(0).getCell(0).getStringCellValue());
+        assertEquals("\u0161\u017E\u010D\u0148\u0159", sheet.getRow(1).getCell(0).getStringCellValue());
+    }
+
 }