#region 检测Excel导入的日期列,防止转换出错 不确定传进来的是duble还是datime DateTime taskplanStartDate; DateTime taskplanEndDate; double typeValue; if (double.TryParse(planStartDate, out typeValue)) { taskplanStartDate = DateTime.FromOADate(Convert.ToDouble(planStartDate)); } else { taskplanStartDate = Convert.ToDateTime(planStartDate); } if (double.TryParse(planEndDate, out typeValue)) { taskplanEndDate = DateTime.FromOADate(Convert.ToDouble(planEndDate)); } else { taskplanEndDate = Convert.ToDateTime(planEndDate); } #endregion