@@ -43,6 +43,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
4343import org .apache .poi .ss .usermodel .DataFormatter ;
4444import org .apache .poi .ss .usermodel .Font ;
4545import org .apache .poi .ss .usermodel .FormulaError ;
46+ import org .apache .poi .ss .usermodel .FormulaEvaluator ;
4647import org .apache .poi .ss .usermodel .RichTextString ;
4748import org .apache .poi .ss .usermodel .Row ;
4849import 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." );
0 commit comments