From 7b02f24e4767ac64c2ee83fc3063c0230804f8b0 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 24 Nov 2021 09:55:33 +0000 Subject: [github-281] Thanks to This closes #281 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895284 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/ss/tests/format/TestCellFormatPart.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'poi-ooxml') diff --git a/poi-ooxml/src/test/java/org/apache/poi/ss/tests/format/TestCellFormatPart.java b/poi-ooxml/src/test/java/org/apache/poi/ss/tests/format/TestCellFormatPart.java index 101fa6c10e..18254af451 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/ss/tests/format/TestCellFormatPart.java +++ b/poi-ooxml/src/test/java/org/apache/poi/ss/tests/format/TestCellFormatPart.java @@ -29,6 +29,7 @@ import java.util.regex.Pattern; import javax.swing.JLabel; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.ITestDataProvider; import org.apache.poi.ss.format.CellFormat; import org.apache.poi.ss.format.CellFormatPart; @@ -217,4 +218,22 @@ class TestCellFormatPart { } } } + + @Test + void testDecimalFormat() throws Exception { + // Create a workbook, row and cell to test with + try (Workbook wb = new HSSFWorkbook()) { + Sheet sheet = wb.createSheet(); + Row row = sheet.createRow(0); + Cell cell = row.createCell(0); + + CellFormat cf = CellFormat.getInstance("[<=.01]0.00%;#,##0"); + + cell.setCellValue(1); + assertEquals("1", cf.apply(cell).text); + + cell.setCellValue(.001); + assertEquals("0.10%", cf.apply(cell).text); + } + } } -- cgit v1.2.3