public static String importByExcelForDate(Cell cell) {
String currentCellValue = "";
switch (cell.getCellType()) {
case STRING:
currentCellValue=cell.getRichStringCellValue().getString();
break;
case NUMERIC: //数字类型 注:excel读取时间是数字类型 并非字符串
if ((DateUtil.isCellDateFormatted(cell))){
Date d = cell.getDateCellValue();
DateFormat formater = new SimpleDateFormat("yyyy/MM/dd");
currentCellValue=formater.format(d);
}else {
cell.setCellType(CellType.STRING);
currentCellValue = cell.getStringCellValue();
}
break;
default:
currentCellValue= cell.getRichStringCellValue().getString();
}
return currentCellValue;
}
POI 4.1版本 解决导入Excel读取数据 1.0转1,日期03-九月-2022日期
最新推荐文章于 2024-05-23 17:18:33 发布