Hi,

I've just stumbled across a bug in POI 3.6:

cell.setCellType(Cell.CELL_TYPE_NUMERIC);

doesn't work if the cell is anything other than blank or a numeric
cell - which kinda defeats the purpose of the whole thing...

It turns out that HSSFCell.java does a

getNumericCellValue()

as part of the setCellType() call (XSSF doesn't have this problem).

The workaround is to first set the cell type to blank, then to numeric, like so:

cell.setCellType(Cell.CELL_TYPE_BLANK);
cell.setCellType(Cell.CELL_TYPE_NUMERIC);

While we're on the subject, I've never understood why
getNumericCellValue() doesn't try to parse the string value in case of
a text cell ? I wouldn't expect that to cause any bad side effects ?
(in fact, excel displays a warning when it detects this situation).

Hopefully someone can put a fix in for this in 3.7...

Thanks,
- Filip

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to