需求:讀取這裏面的數字3orm
實現:get
public String getCellValue(HSSFCell cell) {
String value = null;
if (cell != null) {
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_FORMULA:
// cell.getCellFormula();
try {
value = String.valueOf(cell.getNumericCellValue());
} catch (IllegalStateException e) {
value = String.valueOf(cell.getRichStringCellValue());
}
break;
case HSSFCell.CELL_TYPE_NUMERIC:
value = String.valueOf(cell.getNumericCellValue());
break;
case HSSFCell.CELL_TYPE_STRING:
value = String.valueOf(cell.getRichStringCellValue());
break;
}
}it
return switchNumeric(value);
}io
public static String switchNumeric(String str){
if(str.indexOf(".")>0){
str = str.replaceAll("0+?$", "").replaceAll("[.]$", "");;
}
return str;
} im