public String getCellValue(Cell cell) {
String value = "";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
if (cell != null){
switch (cell.getCellTypeEnum()) {
case STRING:
value = cell.getRichStringCellValue().getString();
break;
case NUMERIC:
String debug_str = cell.getCellStyle().getDataFormatString();
if ("m/d/yy".equals(cell.getCellStyle().getDataFormatString()) || "yyyy\\-mm\\-dd".equals(cell.getCellStyle().getDataFormatString())) {
value = sdf.format(cell.getDateCellValue());
} else {
DecimalFormat df = new DecimalFormat("#");
value = df.format(cell.getNumericCellValue());
// value = String.valueOf(cell.getNumericCellValue());
}
break;
case BOOLEAN:
value = String.valueOf(cell.getBooleanCellValue());
break;
default:
break;
}
}
return RegexUtils.trimSpaceTag(value);
}
暂无评论