aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2013-10-31 16:53:03 +0000
committerNick Burch <nick@apache.org>2013-10-31 16:53:03 +0000
commit374ea84aa6c74a0a0bb540958be41eb90c9cf7a5 (patch)
tree7977ede1a366c155bd0114831587cd7177d589ec /src/testcases/org
parent2bd3296911e74f25f8d12a7b20a2b499b9fd40e2 (diff)
downloadpoi-374ea84aa6c74a0a0bb540958be41eb90c9cf7a5.tar.gz
poi-374ea84aa6c74a0a0bb540958be41eb90c9cf7a5.zip
Allow formatting of formula error cells, giving back the error string that Excel shows #55729
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1537552 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org')
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java b/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
index 6ce19fb5e9..20825e576e 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
@@ -28,6 +28,7 @@ import java.util.Locale;
import junit.framework.TestCase;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.TestHSSFDataFormatter;
/**
@@ -491,6 +492,22 @@ public class TestDataFormatter extends TestCase {
assertEquals(" - ", dfUS.formatRawCellContents(0.0, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-"));
assertEquals(" $- ", dfUS.formatRawCellContents(0.0, -1, "_-$* #,##0.00_-;-$* #,##0.00_-;_-$* \"-\"??_-;_-@_-"));
}
+
+ public void testErrors() {
+ DataFormatter dfUS = new DataFormatter(Locale.US, true);
+
+ // Create a spreadsheet with some formula errors in it
+ Workbook wb = new HSSFWorkbook();
+ Sheet s = wb.createSheet();
+ Row r = s.createRow(0);
+ Cell c = r.createCell(0, Cell.CELL_TYPE_ERROR);
+
+ c.setCellErrorValue(FormulaError.DIV0.getCode());
+ assertEquals(FormulaError.DIV0.getString(), dfUS.formatCellValue(c));
+
+ c.setCellErrorValue(FormulaError.REF.getCode());
+ assertEquals(FormulaError.REF.getString(), dfUS.formatCellValue(c));
+ }
/**
* TODO Fix these so that they work