作者:乔山办公网日期:
返回目录: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 "";
}
试试这个、