NutzCN Logo
问答 上传excel表格,日期都转成数字了,比如上传 2014年4月11日 他会转成41740
发布于 2698天前 作者 zozoh44 1626 次浏览 复制 上一个帖子 下一个帖子
标签:

private static String getCellString(Cell cell) {
Object result = null;
if (cell != null) {
// 单元格类型:Numeric:0,String:1,Formula:2,Blank:3,Boolean:4,Error:5
int cellType = cell.getCellType();
switch (cellType) {
case HSSFCell.CELL_TYPE_STRING:
result = cell.getRichStringCellValue().getString();
break;
case HSSFCell.CELL_TYPE_NUMERIC:
result = cell.getNumericCellValue();
break;
case HSSFCell.CELL_TYPE_FORMULA:
result = cell.getNumericCellValue();
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
result = cell.getBooleanCellValue();
break;
case HSSFCell.CELL_TYPE_BLANK:
result = null;
break;
case HSSFCell.CELL_TYPE_ERROR:
result = null;
break;
default:
break;
}
}
if (result == null) {
return "";
} else {
return result.toString().replace(" ", "");
}
}

2 回复

插入代码的按钮形同虚设

Object result = row.getCell(i).getDateCellValue();

添加回复
请先登陆
回到顶部