在使用poi读取excel时报错为:Cannot get a text value from a numeric cell
刚开始的写法为:
Cell cell = row.getCell(j);
if (cell == null) {
continue;
}
switch(cell.getCellType()){
case Cell.CELL_TYPE_BOOLEAN :
cell.getBooleanCellValue();
case Cell.CELL_TYPE_STRING :
cell.getStringCellValue();
case Cell.CELL_TYPE_NUMERIC:
cell.getNumericCellValue();
}
后改为:
Cell cell = row.getCell(j);
if (cell == null) {
continue;
}
cell.setCellType(Cell.CELL_TYPE_STRING);
str = cell.getStringCellValue();
就不报错了。