Excel

一、

public class ExcelUtils {


    public static String parseCellToString(Cell cell){

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");

        String result = "";

        if(cell.getCellTypeEnum().equals(CellType.STRING)){

            result=cell.getStringCellValue();

        }else if(cell.getCellTypeEnum().equals(CellType.BLANK)){

            result="";

        }else if (cell.getCellTypeEnum().equals(CellType.FORMULA)){

            result = cell.getCellFormula();

        }else  if(cell.getCellTypeEnum().equals(CellType.NUMERIC)){

            if(HSSFDateUtil.isCellDateFormatted(cell)){

                Date date = cell.getDateCellValue();

                result = sdf.format(date);

            }else {

                result = cell.getNumericCellValue()+"";

                result = result.substring(0,result.indexOf("."));

            }

        }

        return result;

    }

}
原文地址:https://www.cnblogs.com/ych961107/p/12023117.html