This might sound like a newbie question, but it's weird. I've tried everything I could come up with, it seems like HSSF simply ignores the format and makes a "general" or "string" cell nonetheless.
This means users get a green arrow for each cell stating an "error" called "Number stored as text"...
Here are some (relevant) excerpts from my code...
HSSFWorkbook book = new HSSFWorkbook();
HSSFSheet sheet = book.createSheet();
HSSFCellStyle cellStyle = book.createCellStyle();
cellStyle.setDataFormat( book.createDataFormat().getFormat("0.00") );
(...)
HSSFRow row = sheet.createRow( y );
(...)
HSSFCell cell = row.createCell( x );
(...)
cell.setCellType( HSSFCell.CELL_TYPE_STRING );
cell.setCellStyle( cellStyle );
cell.setCellValue( Double.parseDouble( orgRow.get( x ) ) );
I have tried commenting the setCellType() and setCellStyle() methods, but that doesn't seem to do anything.
The rest of the code is for-loops, etc. Also, lots of System.err.println(...) of course, to figure out what it's doing.
For example, I've tested using cell.getCellType() in a System.err.println(), but that agrees that the cell is indeed Numeric. However, Excel still gives the error.
I'm using POI release 2.5.1 (the current release), the latest Java+netBeans and Excel 2003.
If anyone could shed some light on this, I'd very much appreciate it.
Frederik Duijn