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  阅读(1347)  评论(0编辑  收藏  举报