From: Nick Burch Date: Wed, 25 Nov 2009 11:33:21 +0000 (+0000) Subject: Fix from Petr for bug #24601 - fix fetching of error codes from XSSF formula cells X-Git-Tag: REL_3_6~30 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ab15ad1b66e1695a6a0c061a6d094f4561ccd966;p=poi.git Fix from Petr for bug #24601 - fix fetching of error codes from XSSF formula cells git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@884058 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index a80cd2e9e6..fcba869f2d 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 24601 - fix fetching of error codes from XSSF formula cells 48229 - fixed javadoc for HSSFSheet.setColumnWidth and XSSFSheet setColumnWidth 47757 - fixed XLSX2CSV to avoid exception when processing cells with multiple "t" elements 48195 - short-circuit evaluation of IF() and CHOOSE() diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java index a9ea533a28..cacc057352 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java @@ -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(); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java index e097bfd140..256bb7bd07 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java @@ -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()); + } }