mirror of https://github.com/apache/poi.git
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:
parent
37bb24ffdf
commit
766300e033
|
@ -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.
Loading…
Reference in New Issue