]> source.dussan.org Git - poi.git/commitdiff
Fix from Petr for bug #24601 - fix fetching of error codes from XSSF formula cells
authorNick Burch <nick@apache.org>
Wed, 25 Nov 2009 11:33:21 +0000 (11:33 +0000)
committerNick Burch <nick@apache.org>
Wed, 25 Nov 2009 11:33:21 +0000 (11:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@884058 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java

index a80cd2e9e686d85c1fd06f7d104d52565ac846d3..fcba869f2d59d4329901d90cca6013d4a749ac35 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.6-beta1" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">24601 - fix fetching of error codes from XSSF formula cells</action>
            <action dev="POI-DEVELOPERS" type="fix">48229 - fixed javadoc for  HSSFSheet.setColumnWidth and XSSFSheet setColumnWidth </action>
            <action dev="POI-DEVELOPERS" type="fix">47757 - fixed XLSX2CSV to avoid exception when processing cells with multiple "t" elements</action>
            <action dev="POI-DEVELOPERS" type="add">48195 - short-circuit evaluation of IF() and CHOOSE()</action>
index a9ea533a28defe0dbf0b5c3a8755d0a8bde86204..cacc05735282181ba9811cc029e35c6382114d90 100644 (file)
@@ -576,7 +576,7 @@ public final class XSSFCell implements Cell {
      * @see FormulaError
      */
     public String getErrorCellString() {
-        int cellType = getCellType();
+        int cellType = getBaseCellType(true);
         if(cellType != CELL_TYPE_ERROR) throw typeMismatch(CELL_TYPE_ERROR, cellType, false);
 
         return _cell.getV();
index e097bfd140355406b4e9f0f8637b6f9828a43646..256bb7bd07a7a4270fdc22a91ce2f0b0ac2f0094 100644 (file)
@@ -166,4 +166,18 @@ public final class TestXSSFCell extends BaseTestCell {
         //make sure we return null for that instead of throwing OutOfBounds
         assertEquals(null, cell.getCellStyle());
     }
+    
+    /**
+     * Cell with the formula that returns error must return error code(There was
+     * an problem that cell could not return error value form formula cell).
+     */
+    public void testGetErrorCellValueFromFormulaCell() {
+        XSSFWorkbook wb = new XSSFWorkbook();
+        XSSFSheet sheet = wb.createSheet();
+        XSSFRow row = sheet.createRow(0);
+        XSSFCell cell = row.createCell(0);
+        cell.setCellFormula("SQRT(-1)");
+        wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCell(cell);
+        assertEquals(36, cell.getErrorCellValue());
+    }
 }