I am using apache poi-3.9 to create Excel (xls) worksheets with some measurement data, which are supposed to be displayed with units within the cell. Units are mbar, mm/sec, and (°) degrees. For mbar and mm/sec everything works perfectly fine, but with degrees formatting gets lost. Microsoft Excel complains with the following error message: "File error. Some number formats may have been lost." Here is my code:
final HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
final HSSFCellStyle cellStyleMbar = hssfWorkbook.createCellStyle(); final HSSFCellStyle cellStyleDegree = hssfWorkbook.createCellStyle();
cellStyleMbar.setDataFormat(dataFormat.getFormat("0 \"mbar\"")); cellStyleDegree.setDataFormat(dataFormat.getFormat("0.0 \"°C"));
Thank you for your ideas!