I need to create a ods document using the Apache ODF Toolking and to format the content of its cells.
I was able to set a format for dates and simple numbers, but for some reason when I try to format with scientific notation it does not work. It fails to parse the string or it wraps the E00 into "E00"
SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument();
document.removeSheet(0);
document.setLocale(Locale.US);
Table sheet = document.appendSheet("My chart");
List<Row> rows = sheet.appendRows(10);
sheet.getColumnByIndex(0).setWidth(27.06);
Row headerRow = rows.get(0);
headerRow.getCellByIndex(0).setStringValue("This is a string");
Row dateRow = rows.get(1);
Calendar date = GregorianCalendar.getInstance();
dateRow.getCellByIndex(0).setDateValue(date);
dateRow.getCellByIndex(0).setFormatString("yyyy-MM-dd");
Row numRow = rows.get(1);
numRow.getCellByIndex(0).setDoubleValue(9.12345678);
//numRow.getCellByIndex(0).setFormatString("0.000"); // works
//numRow.getCellByIndex(0).setFormatString("0.00E+00"); // crashes
numRow.getCellByIndex(0).setFormatString("0.00E00"); // does not work, it becomes 0.00"E00"
document.save(new File("c:\\Users\\enrico\\Desktop\\openoffice.ods"));
I'd really appreciate if anyone could help, thanks.
Full code here https://gist.github.com/EnricoScantamburlo/b06d3a9e52682276b8ca4f6bf51e6f6a