java使用poi解析Excel遇到Cannot get a text value from a numeric cell
2017-12-24 23:04
831 查看
Excel导入操作时偶尔会出现Cannot get a text value from a numeric cell的异常错误
异常原因:Excel数据Cell有不同的类型,在模板中定义该Cell为文本格式,但是用户在插入数据时,调整为数字类型或者其他类型,因此当系统从一个数字类型的Cell读取出一个字符串并写入数据库时,就会出现Cannot get a text value from a numeric cell的异常错误。
解决办法
在java代码中设置Cell的类型,这样就可以把纯数字作为String类型读进来。
异常原因:Excel数据Cell有不同的类型,在模板中定义该Cell为文本格式,但是用户在插入数据时,调整为数字类型或者其他类型,因此当系统从一个数字类型的Cell读取出一个字符串并写入数据库时,就会出现Cannot get a text value from a numeric cell的异常错误。
解决办法
在java代码中设置Cell的类型,这样就可以把纯数字作为String类型读进来。
if(cell != null){ row.getCell(0).setCellType(Cell.CELL_TYPE_STRING); model.setUser(row.getCell(0).getStringCellValue()); }
相关文章推荐
- 使用poi 强制数字转字符串以及Excel导入异常Cannot get a text value from a numeric cell解决
- 使用POI导入Excel并解决Cannot get a text value from a numeric formula cell
- POI操作Excel时出现异常:Cannot get a text value from a numeric cell
- 【POI】 Excel导入异常Cannot get a text value from a numeric cell解决
- POI 读取Excel时:Cannot get a text value from a numeric cell
- poi导入excel表格数据时Cannot get a text value from a numeric cell
- POI操作Excel时出现Cannot get a text value from a numeric cell的异常错误
- Cannot get a text value from a numeric cell “Poi”
- Excel导入异常:Cannot get a text value from a numeric cell
- Excel导入异常Cannot get a text value from a numeric cell解决
- [转]Excel导入异常Cannot get a text value from a numeric cell解决
- 导入Excel出现Cannot get a text value from a numeric cell异常
- Excel导入异常Cannot get a text value from a numeric cell解决
- Excel导入异常Cannot get a text value from a numeric cell解决
- java读写excel时出现Cannot get a NUMERIC value from a STRING cell的解决方法
- Excel导入异常Cannot get a text value from a numeric cell解决
- Excel导入异常Cannot get a text value from a numeric cell解决
- Cannot get a text value from a numeric cell
- java.lang.IllegalStateException: Cannot get a numeric value from a text cel
- Exception in thread "main" java.lang.IllegalStateException: Cannot get a text value from a numeric c