本站不再更新,欢迎光临 java开发技术网
随笔-230  评论-230  文章-8  trackbacks-0

/**
  * 获取cell中的数据
  * @param cell
  * @return
  */
 private String readCell(HSSFCell cell) {
  if (null == cell) {
   return "";
  }
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
  switch (cell.getCellType()) {
   case HSSFCell.CELL_TYPE_STRING: {
    return Strings.trim(cell.getStringCellValue());
   }
   case HSSFCell.CELL_TYPE_NUMERIC: {
    if(HSSFDateUtil.isCellDateFormatted(cell)){
     
     return sdf.format(cell.getDateCellValue());
    }else{
     return Strings.trim(new BigDecimal(cell.getNumericCellValue())
       .toString());
    }

   }
   case HSSFCell.CELL_TYPE_BOOLEAN: {
    return Strings.trim(String.valueOf(cell.getBooleanCellValue()));
   }
   case HSSFCell.CELL_TYPE_FORMULA: {
    return Strings.trim(String.valueOf(cell.getCellFormula()));
   }
   
   default: {
    return Strings.trim(cell.getStringCellValue());
   }
  }
 }

posted on 2006-12-21 16:10 有猫相伴的日子 阅读(1037) 评论(0)  编辑  收藏 所属分类: jdk

只有注册用户登录后才能发表评论。


网站导航:
 
本站不再更新,欢迎光临 java开发技术网