我正在使用Apache POI库读取Excel文件。当我尝试读取密码单元格时遇到了问题。如果用户将日期作为密码输入,例如“16/05/2012”,我读取的值是“41045”,而实际应该是“16/05/2012”。这是我的代码:
cell = row.getCell(); // date in the cell password '16/05/2012'
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_STRING:
cellValue = cell.getRichStringCellValue().getString();
break;
case HSSFCell.CELL_TYPE_NUMERIC:
if(cellCount == TEMPLATE_PASSWORD) {// if cell is password
cell.setCellType(Cell.CELL_TYPE_STRING);
cellValue = cell.getRichStringCellValue().getString(); // value read is 41045 and not "16/05/2012"
}
break;
default:
}
有人可以帮忙吗?
谢谢。