Skip to content

Commit 05e8a16

Browse files
committed
1 parent 0a6a042 commit 05e8a16

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
4343
import org.apache.poi.ss.usermodel.DataFormatter;
4444
import org.apache.poi.ss.usermodel.Font;
4545
import org.apache.poi.ss.usermodel.FormulaError;
46+
import org.apache.poi.ss.usermodel.FormulaEvaluator;
4647
import org.apache.poi.ss.usermodel.RichTextString;
4748
import org.apache.poi.ss.usermodel.Row;
4849
import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
@@ -1398,6 +1399,21 @@ void checkNewFileForR1C1Refs() throws IOException {
13981399
}
13991400
}
14001401

1402+
@Test
1403+
void testGithub321() throws Exception {
1404+
try (XSSFWorkbook wb = openSampleWorkbook("github-321.xlsx")) {
1405+
XSSFSheet xssfSheet = wb.getSheetAt(0);
1406+
DataFormatter dataFormatter = new DataFormatter();
1407+
FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
1408+
XSSFCell a3 = xssfSheet.getRow(2).getCell(0);
1409+
assertEquals("2.05", dataFormatter.formatCellValue(a3));
1410+
assertEquals("2.05", dataFormatter.formatCellValue(a3, formulaEvaluator));
1411+
XSSFCell a4 = xssfSheet.getRow(3).getCell(0);
1412+
assertEquals("2.1", dataFormatter.formatCellValue(a4));
1413+
assertEquals("2.1", dataFormatter.formatCellValue(a4, formulaEvaluator));
1414+
}
1415+
}
1416+
14011417
private static void expectFormattedContent(Cell cell, String value) {
14021418
assertEquals(value, new DataFormatter().formatCellValue(cell),
14031419
"Cell " + ref(cell) + " has wrong formatted content.");
7.93 KB
Binary file not shown.

0 commit comments

Comments
 (0)