private static String getCellValue(XSSFCell cell)
{
String cellValue = null;
if (cell == null) return null;
switch (cell.getCellType())
{
case HSSFCell.CELL_TYPE_NUMERIC :
if (HSSFDateUtil.isCellDateFormatted(cell))
{
SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
cellValue = sdf.format(HSSFDateUtil.getJavaDate(cell
.getNumericCellValue()));
break;
}
String v=String.format("%.4f",cell.getNumericCellValue());
cellValue=(v).replaceAll("\\.0*$","");
break;
case HSSFCell.CELL_TYPE_STRING :
cellValue = String.valueOf(cell.getStringCellValue());
break;
case HSSFCell.CELL_TYPE_FORMULA ://XSSFCell.getCTCell()
cellValue = cell.getCTCell().getV();
break;
case HSSFCell.CELL_TYPE_BLANK :
cellValue = null;
break;
case HSSFCell.CELL_TYPE_BOOLEAN :
cellValue = String.valueOf(cell.getBooleanCellValue());
break;
case HSSFCell.CELL_TYPE_ERROR :
cellValue = String.valueOf(cell.getErrorCellValue());
break;
}
if (cellValue != null && cellValue.trim().length() <= 0)
{
cellValue = null;
}
return cellValue;
}
switch (cell.getCellType()){
case Cell.CELL_TYPE_NUMERIC:
cellValue = stringDateProcess(cell);
break;
case Cell.CELL_TYPE_STRING:
cellValue = String.valueOf(cell.getStringCellValue());
break;
case Cell.CELL_TYPE_BOOLEAN:
cellValue = String.valueOf(cell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_FORMULA:
cellValue = String.valueOf(cell.getCellFormula());
break;
case Cell.CELL_TYPE_BLANK:
cellValue = "";
break;
case Cell.CELL_TYPE_ERROR:
cellValue = "非法字符";
break;
default:
cellValue = "未知类型";
break;
}