【发布时间】:2012-05-23 22:06:16
【问题描述】:
我正在使用 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:
}
有人可以帮忙吗?
谢谢。
【问题讨论】:
-
看看这个帖子,和你的问题差不多。 stackoverflow.com/questions/3148535/…
-
@mashhur 在您的链接上,根据我的要求没有解决方案。
-
我认为您收到的是数字而不是字符串,因为单元格的类型是数字。您确定密码单元格的数字类型正确吗?
标签: java apache-poi