我正在使用POI HSSF API进行Java中的excel操作.我在我的一个excel单元格中有一个日期值"8/1/2009",当我尝试使用HSSF API读取该值时,它会将单元格类型检测为Numeric并返回我的日期的"Double"值.请参阅以下示例代码:
cell = row.getCell(); // date in the cell '8/1/2009'
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_STRING:
cellValue = cell.getRichStringCellValue().getString();
break;
case HSSFCell.CELL_TYPE_NUMERIC:
cellValue = new Double(cell.getNumericCellValue()).toString();
break;
default:
}
Run Code Online (Sandbox Code Playgroud)
Cell.getCellType()返回NUMERIC_TYPE,因此此代码将日期转换为double!:(
有没有办法在HSSF POI中读取日期!