//獲取cell的數據,並設置爲對應的數據類型 public object GetCellValue(ICell cell) { object value = null; try { if (cell.CellType != CellType.Blank) { switch (cell.CellType) { case CellType.Numeric: // Date Type的數據CellType是Numeric if (DateUtil.IsCellDateFormatted(cell)) { value = cell.DateCellValue; } else { // Numeric type value = cell.NumericCellValue; } break; case CellType.Boolean: // Boolean type value = cell.BooleanCellValue; break; default: // String type value = cell.StringCellValue; break; } } } catch (Exception) { value = ""; } return value; }