white-knight
public static String getCellValue(XSSFCell cell) {
        if (cell == null) {
            return "";
        }
        switch (cell.getCellType()) {
            case Cell.CELL_TYPE_STRING:
                String tmp = cell.getStringCellValue().trim();
                return StringUtils.isEmpty(tmp) ? "" : tmp;
            case Cell.CELL_TYPE_NUMERIC:
                if (HSSFDateUtil.isCellDateFormatted(cell)) {
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    return sdf.format(cell.getDateCellValue());
                } else {
                    return new DecimalFormat("#.######").format(cell.getNumericCellValue());
                }
            case Cell.CELL_TYPE_BOOLEAN:
                return String.valueOf(cell.getBooleanCellValue());
            case Cell.CELL_TYPE_BLANK:
                return "";
            case Cell.CELL_TYPE_ERROR:
                return "";
            case Cell.CELL_TYPE_FORMULA:
                return String.valueOf(cell.getCellFormula().trim());
            default:
                return "";
        }
    }

 

posted on 2018-07-18 16:05  white knight  阅读(1242)  评论(0编辑  收藏  举报

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-01-07
  • 2021-10-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-09
  • 2021-10-29
  • 2021-12-09
  • 2021-04-19
  • 2021-12-19
  • 2021-09-05
相关资源
相似解决方案