aboutsummaryrefslogtreecommitdiffstats
path: root/poi
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2024-07-02 09:08:40 +0000
committerPJ Fanning <fanningpj@apache.org>2024-07-02 09:08:40 +0000
commit04c9d0a3c12a828559ae5a5db9e29e881e8f8ef1 (patch)
tree27e8ad88ccec5e847354e685b1e974b742a12cae /poi
parent05c79326befab7697466db902b76b96c72f6a698 (diff)
downloadpoi-04c9d0a3c12a828559ae5a5db9e29e881e8f8ef1.tar.gz
poi-04c9d0a3c12a828559ae5a5db9e29e881e8f8ef1.zip
another dataformatter test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1918817 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r--poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java3
-rw-r--r--poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestDataFormat.java20
2 files changed, 23 insertions, 0 deletions
diff --git a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java
index 98195b11d5..610284fbf6 100644
--- a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java
+++ b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java
@@ -29,8 +29,11 @@ import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.ss.usermodel.BaseTestDataFormat;
import org.apache.poi.ss.usermodel.Cell;
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.Row;
import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
import org.junit.jupiter.api.Test;
/**
diff --git a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestDataFormat.java b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestDataFormat.java
index eed2fd3cc3..77ac9154d7 100644
--- a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestDataFormat.java
+++ b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestDataFormat.java
@@ -273,4 +273,24 @@ public abstract class BaseTestDataFormat {
assertEquals("12'345'678", formatter.formatCellValue(lge));
}
}
+
+ @Test
+ public void testFormatCellValueDecimal() throws IOException {
+ DataFormatter df = new DataFormatter();
+
+ try (Workbook wb = _testDataProvider.createWorkbook()) {
+ Cell cell = wb.createSheet("test").createRow(0).createCell(0);
+ assertEquals("", df.formatCellValue(cell));
+
+ cell.setCellValue(1.005);
+ assertEquals("1.005", df.formatCellValue(cell));
+
+ DataFormat format = wb.createDataFormat();
+ CellStyle cellStyle = wb.createCellStyle();
+ cellStyle.setDataFormat(format.getFormat("0.00"));
+ cell.setCellStyle(cellStyle);
+ assertEquals("1.01", df.formatCellValue(cell));
+ }
+ }
+
}