Excel导入Java遇到 Cannot get a numeric value from a text cell

解决方法

Cell cellValue = row.getCell(0);

objFormulaEvaluator.evaluate(cellValue);

String cellValueStr = objDefaultFormat.formatCellValue(cellValue,objFormulaEvaluator);

虽然有很多人也说用直接cell.setCellType(Cell.CELL_TYPE_STRING);但是POIdoc里面写并不推荐这种用法,而且实际我用的时候,编译也未通过。

javadocs声明the only way to convert to a String with formatting remaining is to use the DataFormatter class.

你可能感兴趣的:(Excel导入Java遇到 Cannot get a numeric value from a text cell)