POI中HSSFCELL数值表格类型转换字符串
2020-03-17 本文已影响0人
超音速6
public String getCellValue(HSSFCell cell) {
String value = "";
if (cell != null) {
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_FORMULA:
break;
case HSSFCell.CELL_TYPE_NUMERIC:
DecimalFormat decimalFormat = new DecimalFormat("#");
value = decimalFormat.format(cell.getNumericCellValue()).trim();
break;
case HSSFCell.CELL_TYPE_STRING:
value = cell.getStringCellValue().trim();
break;
default:
value = "";
break;
}
}
return value.trim();
}