原因
Excel中数值类型值在程序中按字符串类型获取
解决
private static String getCellValue(Cell cell) {
String resultValue = "";
if (Objects.isNull(cell)) {
return resultValue;
}
int cellType = cell.getCellType();
switch (cellType) {
case Cell.CELL_TYPE_STRING:
resultValue = StringUtils.isEmpty(cell.getStringCellValue()) ? "" : cell.getStringCellValue().trim();
break;
case Cell.CELL_TYPE_BOOLEAN:
resultValue = String.valueOf(cell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_NUMERIC:
resultValue = new DecimalFormat("#.######").format(cell.getNumericCellValue());
break;
default:
break;
}
return resultValue;
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-24699.html