场景
Excel 文件导入后,纯数字类型的单元格不能通过
getStringCellValue()
方法直接转为String
且原有转换方法
cell.setCellType (CellType.STRING);
不起作用且已经被废弃
新的转为 String 解决方法
// index 为当前行的单元格索引值 即第几个单元格 row 为当前行 通过sheet 获取到
Cell nameCell = row.getCell(index);
String cellValue = new DataFormatter().formatCellValue(nameCell);
formatCellValue() 使用该方法后可以正常读取excel 中的数值且为String