乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > java poi读取日期格式数据“2012-01-01 12...-poi读取excel时间,poi读取excel

java poi读取日期格式数据“2012-01-01 12...-poi读取excel时间,poi读取excel

作者:乔山办公网日期:

返回目录:excel表格制作


zhidaoExcel拿到的都是字符串
在save到数据库之前先进行格式化
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
sdf.format(collValue);

//就可以得到String类型了
String data = 2.05+"";

如果这个时间你不需要用公式计算什么的话。

可以在java代码中,将日期样式,格式化好。以文本的形式输出出来。

public String getCell(HSSFCell cell) {
7a686964616fe78988e69d83330DecimalFormat 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 "";
}

试试这个、

相关阅读

  • -java poi excel模板,java使用poi读取excel

  • 乔山办公网excel表格制作
  • 需要导入jxl.jar (在网上可以下载,然后放到lib文件夹中)开放分类: java通过java操作excel表格的工抄具类库支持Excel 95-2000的所有版本生成Excel 2000标准格式支持字体、数字、日期操作 能够
关键词不能为空
极力推荐

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