Excel导入异常Cannot get a text value from a numeric cell解决
2016-08-15 17:36
561 查看
今天在做项目导入这个功能时,遇到的错误,顺利解决,下面介绍下解决方法
POI操作Excel时偶尔会出现Cannot get a text value from a numeric cell的异常错误。
异常原因:Excel数据Cell有不同的类型,当我们试图从一个数字类型的Cell读取出一个字符串并写入数据库时,就会出现Cannot get a text value from a numeric cell的异常错误。
此异常常见于类似如下代码中:row.getCell(0).getStringCellValue();
解决办法:先设置Cell的类型,然后就可以把纯数字作为String类型读进来了:
if(row.getCell(0)!=null){
row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
stuUser.setPhone(row.getCell(0).getStringCellValue());
}
POI操作Excel时偶尔会出现Cannot get a text value from a numeric cell的异常错误。
异常原因:Excel数据Cell有不同的类型,当我们试图从一个数字类型的Cell读取出一个字符串并写入数据库时,就会出现Cannot get a text value from a numeric cell的异常错误。
此异常常见于类似如下代码中:row.getCell(0).getStringCellValue();
解决办法:先设置Cell的类型,然后就可以把纯数字作为String类型读进来了:
if(row.getCell(0)!=null){
row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
stuUser.setPhone(row.getCell(0).getStringCellValue());
}
相关文章推荐
- Excel导入异常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解决
- 【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
- 使用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的异常错误
- java使用poi解析Excel遇到Cannot get a text value from a numeric cell
- java读写excel时出现Cannot get a NUMERIC value from a STRING cell的解决方法
- POI 读取Excel时:Cannot get a text value from a numeric cell
- Cannot get a text value from a numeric cell “Poi”
- Cannot get a text value from a numeric cell
- HSSFCell:You cannot get a string value from a numeric cell
- Exception in thread "main" java.lang.IllegalStateException: Cannot get a text value from a numeric c