///<summary> /// 判断单元格列的类型 ///</summary> ///<param name="cell"></param> ///<returns></returns> publicstaticobjectGetValueType(ICell cell) { bool flag = cell == null; object result = null; if(flag) result = null; switch(cell.CellType) { case CellType.Boolean: result = cell.BooleanCellValue; break; case CellType.Error: result = cell.ErrorCellValue; break; case CellType.Formula: switch(cell.CachedFormulaResultType) { case CellType.Boolean: result = cell.BooleanCellValue; break; case CellType.Error: result = ErrorEval.GetText(cell.ErrorCellValue); break; case CellType.Numeric: if(DateUtil.IsCellDateFormatted(cell)) { result = cell.DateCellValue.ToString("yyyy-MM-dd hh:MM:ss"); } else { result = cell.NumericCellValue; } break; case CellType.String: string str = cell.StringCellValue; if(!string.IsNullOrEmpty(str)) { result = str.ToString(); } else { result = null; } break; case CellType.Unknown: case CellType.Blank: default: result = string.Empty; break; } break; case CellType.Numeric: if(DateUtil.IsCellDateFormatted(cell)) { result = cell.DateCellValue.ToString("yyyy-MM-dd hh:MM:ss"); } else { result = cell.NumericCellValue; } break; case CellType.String: string strValue = cell.StringCellValue; if(!string.IsNullOrEmpty(strValue)) { result = strValue.ToString(); } else { result = null; } break; case CellType.Unknown: case CellType.Blank: default: result = string.Empty; break; } return result; }