diff options
author | PJ Fanning <fanningpj@apache.org> | 2024-07-02 09:42:02 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2024-07-02 09:42:02 +0000 |
commit | 6e07ce50dd2a065eabd12cb203ef9d94d3f73cf6 (patch) | |
tree | 36f1408ad049b0219ba0d1b6bd55b578521656dd /poi-ooxml/src | |
parent | 04c9d0a3c12a828559ae5a5db9e29e881e8f8ef1 (diff) | |
download | poi-6e07ce50dd2a065eabd12cb203ef9d94d3f73cf6.tar.gz poi-6e07ce50dd2a065eabd12cb203ef9d94d3f73cf6.zip |
add dataformatter test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1918819 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml/src')
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java index ba89baed3d..63faef0c91 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java @@ -31,6 +31,7 @@ import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.DataFormat; import org.apache.poi.ss.usermodel.DataFormatter; import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.util.CellReference; import org.apache.poi.xssf.XSSFITestDataProvider; @@ -148,7 +149,7 @@ public final class TestXSSFDataFormat extends BaseTestDataFormat { assertEquals("TRUE", df.formatCellValue(cell)); CellStyle cellStyle = wb.createCellStyle(); - cellStyle.setDataFormat((short)14); + cellStyle.setDataFormat((short) 14); cell.setCellStyle(cellStyle); cell.setCellValue(new Date(234092383)); assertEquals("1/3/70", df.formatCellValue(cell)); @@ -159,5 +160,19 @@ public final class TestXSSFDataFormat extends BaseTestDataFormat { */ } } - + + @Test + public void testGitHub650() throws IOException { + // https://github.com/apache/poi/pull/650 + DataFormatter df = new DataFormatter(); + + try (Workbook wb = _testDataProvider.openSampleWorkbook("decimal-format.xlsx")) { + Sheet sheet = wb.getSheetAt(0); + Cell cell1 = sheet.getRow(0).getCell(0); + assertEquals("1.01", df.formatCellValue(cell1)); + Cell cell2 = sheet.getRow(1).getCell(0); + assertEquals("1.00", df.formatCellValue(cell2)); + } + } + } |