/// <summary> /// Produces the Excel file of the report for download into Excel format. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnExportExcel_Click(object sender, EventArgs e) { DataTable dt = GetProjectTable(); dt.TableName = "Project"; //DataRow dr = dt.NewRow(); //dr[1] = "Total"; //dr[2] = dt.Rows.Count; //decimal phdHrs = 0.0m, msHrs = 0.0m; //foreach (DataRow row in dt.Rows) //{ // phdHrs += Convert.ToDecimal(row["PhdHrs"].ToString()); // msHrs += Convert.ToDecimal(row["MsHrs"].ToString()); //} //dr[16] = phdHrs; //dr[17] = msHrs; //dt.Rows.Add(dr); /* (Check-in Summary) Report - So Yung Choi - [Short Term/Last 2 Weeks: 6/4/2020-6/18/2020][Reference: 4/1/2020-6/18/2020][Project Start - 6/18/2020] */ string reportHeader = ddlReportType.SelectedIndex.Equals(1) ? "(Check-in Summary) Project Report - " + ReportType + " - [Short Term/Last 2 Weeks: " + FromDate + "-" + ToDate + "] [Reference: " + ReferenceDate + "-" + ToDate + "] [Cumulative: Project Start Date-" + ToDate + "]" : "Project Report - " + ReportType + " - from " + FromDate + " to " + ToDate; string fileName = ddlReportType.SelectedIndex.Equals(1) ? "Check-in_Summary_Project_Report_-_" + ReportType + "_-_" + ToDate : "Project_Report_-_" + ReportType + "_-_from_" + FromDate + "_to_" + ToDate; FileExport fileExport = new FileExport(this.Response); fileExport.ExcelExport2(dt, fileName, reportHeader); //fileExport.ExcelExport(dt, "Project"); }
/// <summary> /// Obtains report based on start/end date parameters and exports it into an excel file. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnExportExcel_Click(object sender, EventArgs e) { int grantId; int reportId; DateTime fromDate, toDate; string fileName = ""; string grantName = ""; string titleName = ""; if (Request["optionsRadios"].ToString() == "option1") { grantId = Convert.ToInt32(ddlGrantType.SelectedValue); } else { grantId = 3; } string collabCenterText = ddlCollabCenter.SelectedItem.Text; //grantId = collabCenterText != "--- Select Collaborative Center ---" ? grantId = 3 : grantId = Convert.ToInt32(ddlGrantType.SelectedValue); //GrantName = grantId == 2 ? "Ola_Hawaii" : // grantId == 1 ? "RMATRIX" : // ddlCollabCenter.SelectedItem.Text; if (/*Int32.TryParse(ddlGrantType.SelectedValue, out grantId) &&*/ Int32.TryParse(ddlReport.SelectedValue, out reportId) && DateTime.TryParse(txtFromDate.Text, out fromDate) && DateTime.TryParse(txtToDate.Text, out toDate)) { DataTable dt = new DataTable(); grantName = grantId == 1 ? "Rmatrix" : grantId == 2 ? "OlaHawaii" : collabCenterText; switch (reportId) { case 11: // (all) projects dt = GetProjectTable(grantId, reportId, fromDate, toDate); dt.TableName = "Project"; if (grantId != 2) { dt.Columns.Remove("HealthData"); dt.Columns.Remove("NonUH"); } break; case 12: // Healthcare Data projects dt = GetProjectTable(grantId, reportId, fromDate, toDate); dt.TableName = "HealthData"; dt.Columns.Remove("HealthData"); dt.Columns.Remove("NonUH"); break; case 13: // NonUH projects dt = GetProjectTable(grantId, reportId, fromDate, toDate); dt.TableName = "NonUH"; dt.Columns.Remove("HealthData"); dt.Columns.Remove("NonUH"); break; case 14: // Publications dt = GetPubTable(grantId, reportId, fromDate, toDate); dt.TableName = "Publications"; dt.Columns.Remove("conf"); dt.Columns.Remove("ConfLoc"); dt.Columns.Remove("StartDate"); dt.Columns.Remove("EndDate"); dt.Columns.Remove("pp"); dt.Columns.Remove("GrantAffilName"); dt.Columns.Remove("FromDate"); dt.Columns.Remove("ToDate"); dt.Columns.Remove("CitationFormat"); dt.Columns.Remove("BiostatName"); //if(grantId != 2) //{ // dt.Columns.Remove("IsOlaFunded"); // dt.Columns.Remove("IsOlaAcknowledged"); // dt.Columns.Remove("IsOlaRequest"); //} break; case 15: // AbstractsPresentations dt = GetPubTable(grantId, reportId, fromDate, toDate); dt.TableName = "AbstractsPresentations"; dt.Columns.Remove("JournalName"); dt.Columns.Remove("pp"); dt.Columns.Remove("pubYear"); dt.Columns.Remove("pubMonth"); dt.Columns.Remove("Volume"); dt.Columns.Remove("Issue"); dt.Columns.Remove("Page"); dt.Columns.Remove("DOI"); dt.Columns.Remove("PMID"); dt.Columns.Remove("PMCID"); dt.Columns.Remove("GrantAffilName"); dt.Columns.Remove("FromDate"); dt.Columns.Remove("ToDate"); dt.Columns.Remove("CitationFormat"); dt.Columns.Remove("BiostatName"); //if (grantId != 2) //{ // dt.Columns.Remove("IsOlaFunded"); // dt.Columns.Remove("IsOlaAcknowledged"); // dt.Columns.Remove("IsOlaRequest"); //} break; case 16: // Academic dt = GetAcademicTable(grantId, reportId, fromDate, toDate); dt.TableName = "Academic"; dt.Columns.Remove("Column1"); dt.Columns.Remove("Column2"); break; default: break; } titleName = GrantName + " " + ReportType + " Report from " + FromDate + " to " + ToDate; fileName = GrantName + "-" + ReportType + "-" + "Report-From" + "-" + FromDate + "-" + "To" + "-" + ToDate; fileName = fileName.Replace(" ", "_"); FileExport fileExport = new FileExport(this.Response); fileExport.ExcelExport2(dt, fileName, titleName); } }