java excel 单元格类型,POI Excel 单元格内容类型判断并取值

个人用到的

String birthdayVal = null;

switch (cell_2.getCellTypeEnum()) {

case STRING:

birthdayVal = cell_2.getRichStringCellValue().getString();

break;

case NUMERIC:

if("General".equals(cell_2.getCellStyle().getDataFormatString())){

birthdayVal =DateToStr(HSSFDateUtil.getJavaDate(cell_2.getNumericCellValue()));

}else if("m/d/yy".equals(cell_2.getCellStyle().getDataFormatString())){

birthdayVal = DateToStr(cell_2.getDateCellValue());

}else{

birthdayVal = DateToStr(HSSFDateUtil.getJavaDate(cell_2.getNumericCellValue()));

}

break;

default:

x = i+1;

throw new AWSForbiddenException("导入文件的第["+x+"]行的[出生年月]的格式有问题,请检查!",null);

}

/**

* 日期转换成字符串

*/

public static String Date

你可能感兴趣的:(java,excel,单元格类型)