错误原因:jar包版本更新,官方改动;
解决方法:
导入CellType包import org.apache.poi.ss.usermodel.CellType
使用CellType.STRING代替HSSFCell.CELL_TYPE_STRING
其他同理。
https://www.cnblogs.com/sengzhao666/p/11144902.html参考)
新版:
if(cell==null||cell.equals(null)||cell.getCellType()==CellType.BLANK){
value="null";
}else {
//判断数据类型
switch (cell.getCellType()) {
case FORMULA:value = "" + cell.getCellFormula();
break;
case NUMERIC:value = "" + cell.getNumericCellValue();
break;
case STRING:value = cell.getStringCellValue();
break;
default:
break;
}
}
旧版:
if(cell==null||cell.equals("")||cell.getCellType()==HSSFCell.CELL_TYPE_BLANK){
value="null";
}else {
//判断数据类型
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_FORMULA:value = "" + cell.getCellFormula();
break;
case HSSFCell.CELL_TYPE_NUMERIC:value = "" + cell.getNumericCellValue();
break;
case HSSFCell.CELL_TYPE_STRING:value = cell.getStringCellValue();
break;
default:
break;
}
}