Bug 57236: Add reproducer, although I am not sure if we should and how to fix this...

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1647254 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2014-12-22 07:57:03 +00:00
parent c975b754d1
commit 12353bca7f
2 changed files with 30 additions and 0 deletions

View File

@ -25,6 +25,7 @@ import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.ss.usermodel.Cell;
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;
@ -104,4 +105,33 @@ public final class TestUnfixedBugs extends TestCase {
}
}
}
public void test57236() {
// Having very small numbers leads to different formatting, Excel uses the scientific notation, but POI leads to "0"
/*
DecimalFormat format = new DecimalFormat("#.##########", new DecimalFormatSymbols(Locale.getDefault()));
double d = 3.0E-104;
assertEquals("3.0E-104", format.format(d));
*/
DataFormatter formatter = new DataFormatter(true);
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57236.xlsx");
for(int sheetNum = 0;sheetNum < wb.getNumberOfSheets();sheetNum++) {
Sheet sheet = wb.getSheetAt(sheetNum);
for(int rowNum = sheet.getFirstRowNum();rowNum < sheet.getLastRowNum();rowNum++) {
Row row = sheet.getRow(rowNum);
for(int cellNum = row.getFirstCellNum();cellNum < row.getLastCellNum();cellNum++) {
Cell cell = row.getCell(cellNum);
String fmtCellValue = formatter.formatCellValue(cell);
System.out.println("Cell: " + fmtCellValue);
assertNotNull(fmtCellValue);
assertFalse(fmtCellValue.equals("0"));
}
}
}
}
}

Binary file not shown.