关于对cell中的类型判断:
项目部分代码:
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_BOOLEAN:
result = String.valueOf(cell.getBooleanCellValue());
break;
case HSSFCell.CELL_TYPE_NUMERIC:
if (HSSFDateUtil.isCellDateFormatted(cell)) {
java.text.SimpleDateFormat TIME_FORMATTER = new java.text.SimpleDateFormat(
"yyyy-MM-dd");
result = TIME_FORMATTER.format(cell.getDateCellValue());
}
else{
String str=null;
double doubleValue = cell.getNumericCellValue();
// 是否为数值型
double d = cell.getNumericCellValue();
if (doubleValue - (int) doubleValue < Double.MIN_VALUE) {
// 是否为int型
str = Integer.toString((int) doubleValue);
} else {
System.out.println("double.....");
// 是否为double型
str = Double.toString(cell.getNumericCellValue());
DecimalFormat