public FileResult SurveyExport(string ExportType, FormCollection FormData) { Dictionary<string, string> sitemaster = GetSiteMaster(); int UserId = Convert.ToInt32(sitemaster["userid"]); Dictionary<string, string> FormDict = ParmHelper.Analysis(FormData); ProjectDao ProjectD = new ProjectDao(); ScheduleDao SchDao = new ScheduleDao(); IList<IDictionary> ProjectList = ProjectD.ProjectExport<IDictionary>(FormDict); DateTime Now = DateTime.Now; DateTime DateStart = Now; DateTime DateEnd = Now; switch (ExportType) { case "day": DateStart = Convert.ToDateTime(Now.ToShortDateString() + " 00:00"); DateEnd = Convert.ToDateTime(Now.ToShortDateString() + " 23:59"); break; case "week": DateStart = Now.AddDays(1 - Convert.ToInt32(Now.DayOfWeek.ToString("d"))); DateEnd = DateStart.AddDays(6); break; case "month": DateStart = Now.AddDays(1 - Now.Day); DateEnd = Now.AddMonths(1).AddDays(-1); break; default: break; } string result = string.Empty; foreach (var Project in ProjectList) { IList<IDictionary> DayScheduleList = SchDao.GetDateSchedule<IDictionary>(Convert.ToInt32(Project["Id"]), UserId, DateStart, DateEnd); //if (DayScheduleList.Count > 0) //{ result += ExportStr(Project, DayScheduleList); //} } byte[] data = Encoding.UTF8.GetBytes(result.ToString()); return File(data, "application/ms-excel", "export.xls"); }