public String getCell(HSSFCell cell) { e" />
乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > <em>java</em> poi读取excel日期格式数据-excel导入日期 java,ja

<em>java</em> poi读取excel日期格式数据-excel导入日期 java,ja

作者:乔山办公网日期:

返回目录:excel表格制作


数值.toString()就变成字符串了嘛。

public String getCell(HSSFCell cell) {
e5a48de588b6e79fa5e98193330DecimalFormat df = new DecimalFormat("#");
if (cell == null)
return "";
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_NUMERIC:
if(HSSFDateUtil.isCellDateFormatted(cell)){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(HSSFDateUtil.getJavaDate(cell.getNumericCellValue())).toString();
}
return df.format(cell.getNumericCellValue());
case HSSFCell.CELL_TYPE_STRING:
System.out.println(cell.getStringCellValue());
return cell.getStringCellValue();
case HSSFCell.CELL_TYPE_FORMULA:
return cell.getCellFormula();
case HSSFCell.CELL_TYPE_BLANK:
return "";
case HSSFCell.CELL_TYPE_BOOLEAN:
return cell.getBooleanCellValue() + "";
case HSSFCell.CELL_TYPE_ERROR:
return cell.getErrorCellValue() + "";
}
return "";
}

试试这个、
aRow.getCell(时间所在的列数).setCellType(Cell.CELL_TYPE_STRING);
让它变成string

Java的不会,但是思路应该是差不多的,你数据为Null那你就用三元表达式判断,如果为Null就赋一个值给它。(请自行百度三元表达式)

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网