/**
* <p>
* Description:判断时间类型
* </p>
*
* @param sheet sheet
* @param i 行
* @param colIndex 列
* @return val 返回的string
*/
public static String toNumeric(XSSFSheet sheet, int i, int colIndex) {
Cell cell = sheet.getRow(i).getCell(colIndex);
String val = null;
switch (cell.getCellType()) {
case Cell.CELL_TYPE_STRING:
val = cell.getStringCellValue();
break;
case Cell.CELL_TYPE_BOOLEAN:
Boolean val1 = cell.getBooleanCellValue();
val = val1.toString();
break;
case Cell.CELL_TYPE_NUMERIC:
if(XSSFDateUtil.isCellDateFormatted(cell)){ //日期类型
val=cell.toString();
}else{
DecimalFormat df = new DecimalFormat("0");
val = df.format(cell.getNumericCellValue()); //数值类型的
}
break;
case Cell.CELL_TYPE_BLANK:
break;
}
return val;
}
public static class XSSFDateUtil extends DateUtil {
protected static int absoluteDay(Calendar cal, boolean use1904windowing) {
return DateUtil.absoluteDay(cal, use1904windowing);
}
}