Take the 2-minute tour ×

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!

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

The problem is probably that you don't close the quoted text in the format template.


dataFormat.getFormat("0.0 \"°C")


dataFormat.getFormat("0.0 \"°C\"")

share|improve this answer
Indeed! Just overlooked. Thank you! –  igor-so Jan 30 '13 at 16:04
add comment

Your Answer


