为什么在 Apache POI 中更改单元格类型是非法的?下面的代码导致IllegalStateException: Cannot get a error value from a numeric cell
.
Cell mycell = myrow.createCell(0);
// Make it numeric by default.
mycell.setCellType(Cell.CELL_TYPE_NUMERIC);
if (someCondition) {
mycell.setCellType(Cell.CELL_TYPE_STRING); // IllegalStateException
}
有没有办法解决这个问题(如不引入额外的逻辑)?