首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

java读取Excel时判断数据的部类

2012-08-01 
java读取Excel时判断数据的类型if (cellType HSSFCell.CELL_TYPE_NUMERIC) {   Date date cell.getDa

java读取Excel时判断数据的类型
if (cellType == HSSFCell.CELL_TYPE_NUMERIC) {
  Date date = cell.getDateCellValue();
  result = (date.getYear() + 1900) + "-" + (date.getMonth() + 1)
  + "-" + date.getDate();
  } else if (cellType == HSSFCell.CELL_TYPE_STRING) {
  String date = getStringCellValue(cell);
  result = date.replaceAll("[年月]", "-").replace("日", "").trim();
  } else if (cellType == HSSFCell.CELL_TYPE_BLANK) {
  result = "";
  }
  } catch (Exception e) {
  System.out.println("日期格式不正确!");
  e.printStackTrace();
  }

热点排行