我正在尝试使用 apache poi 库来读取 Excel。我想将日期字段转换为字符串值。因此我使用了以下代码:
if(cell.getCellType()==Cell.CELL_TYPE_NUMERIC){
if(DateUtil.isCellDateFormatted(cell)){
DataFormatter df = new DataFormatter();
FormulaEvaluator fe = Workbook.getCreationHelper().createFormulaEvaluator();
String str= formatter.formatCellValue(cell, fe);
return str;
}
}
我收到奇怪形式的日期,即<3/12/[]15>。单元格值 ID 3/12/2015。任何人都可以指导我吗?
最佳答案
而不是像这样重写 DateFormatter:
if(cell.getCellType()==Cell.CELL_TYPE_NUMERIC){
String date = cell.getDateCellValue();
}
}
关于java - 使用 apache poi 从 excel 读取日期作为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31443048/