private void ExportData(String F_ID, String selectCMD) { SqlDataAdapter adapter = new SqlDataAdapter(); String orderCmd = " order by F_seq "; String sql = "select F_code, F_name, F_leader, F_unit, F_type, CONVERT(varchar(100), F_applicantDate, 23), CONVERT(varchar(100), F_completeDate, 23) , F_status, F_fund from ViewAuditedBySchool where "; adapter.SelectCommand = new SqlCommand(sql + selectCMD + orderCmd); adapter.SelectCommand.Connection = new SqlConnection(UtilHelper.ConnectionString); DataTable dt = new DataTable(); adapter.Fill(dt); if (dt.Rows.Count == 0) { UtilHelper.AlertMsg("没有数据"); return; } sql = "select F_code, F_name, F_leader, F_unit, F_type, CONVERT(varchar(100), F_applicantDate, 23), CONVERT(varchar(100), F_completeDate, 23) , " + " F_status, F_fund from ViewAuditedBySchool where F_projectType='科技项目' and "; adapter.SelectCommand = new SqlCommand(sql + selectCMD + orderCmd); adapter.SelectCommand.Connection = new SqlConnection(UtilHelper.ConnectionString); dt = new DataTable(); adapter.Fill(dt); DataClassesDataContext dc = new DataClassesDataContext(); ProjectDetail projectDetail = dc.ProjectDetail.SingleOrDefault(_pd => _pd.F_ID.Equals(F_ID)); String sciFileName = Server.MapPath("/resource/" + UtilHelper.getValidatePath(projectDetail.F_code) + "科技项目汇总表.xls"); ExportFile(dt, sciFileName); sql = "select F_code, F_name, F_leader, F_unit, F_type, CONVERT(varchar(100), F_applicantDate, 23), CONVERT(varchar(100), F_completeDate, 23) , " + " F_status, F_fund from ViewAuditedBySchool where F_projectType='社科项目' and "; adapter.SelectCommand = new SqlCommand(sql + selectCMD + orderCmd); adapter.SelectCommand.Connection = new SqlConnection(UtilHelper.ConnectionString); dt = new DataTable(); adapter.Fill(dt); String socialFileName = Server.MapPath("/resource/" + UtilHelper.getValidatePath(projectDetail.F_code) + "社科项目汇总表.xls"); ExportFile(dt, socialFileName); List <String> outputFiles = new List <string>(); if (File.Exists(sciFileName)) { outputFiles.Add(sciFileName); } if (File.Exists(socialFileName)) { outputFiles.Add(socialFileName); } String zipFile = Server.MapPath("/resource/" + UtilHelper.getValidatePath(projectDetail.F_code) + "项目汇总表.zip"); UtilHelper.ZipFileMain(outputFiles, zipFile); DownloadFile("项目汇总表.zip", zipFile); }