public byte[] GetDataToExportCareTeamSurvey(CareTeamSurvey careTeamSurvey, HospitalDetailsDto hospitalDetails) { string fileName = @"C:\Escalation_CareTeam_Report_" + Guid.NewGuid() + ".xlsx"; var configureCells = new ConfigureEscalationReport(); var workbook = new XLWorkbook(); var worksheet = workbook.Worksheets.Add("Survey Escalation Report"); configureCells.ConfigureCell(worksheet,careTeamSurvey.Survey.SurveyType); #region Headers worksheet.Cell("A1").Value = "Survey Type"; worksheet.Cell("B1").Value = "Region"; worksheet.Cell("C1").Value = "Site"; worksheet.Cell("D1").Value = "Site #"; worksheet.Cell("E1").Value = "Date of Survey"; worksheet.Cell("F1").Value = careTeamSurvey.Question3A.QuestionText; worksheet.Cell("G1").Value = careTeamSurvey.Question3B.QuestionText; worksheet.Cell("H1").Value = careTeamSurvey.Question3C.QuestionText; worksheet.Cell("I1").Value = careTeamSurvey.Question3D.QuestionText; worksheet.Cell("J1").Value = careTeamSurvey.Question3E.QuestionText; worksheet.Cell("K1").Value = careTeamSurvey.Question3F.QuestionText; worksheet.Cell("L1").Value = careTeamSurvey.Question3G.QuestionText; worksheet.Cell("M1").Value = careTeamSurvey.Question3H.QuestionText; worksheet.Cell("N1").Value = careTeamSurvey.Question3I.QuestionText; worksheet.Cell("O1").Value = careTeamSurvey.Question3J.QuestionText; worksheet.Cell("P1").Value = careTeamSurvey.Question3K.QuestionText; worksheet.Cell("Q1").Value = careTeamSurvey.Question3L.QuestionText; worksheet.Cell("R1").Value = careTeamSurvey.Question3M.QuestionText; worksheet.Cell("S1").Value = careTeamSurvey.Question3N.QuestionText; worksheet.Cell("T1").Value = careTeamSurvey.Question3O.QuestionText; worksheet.Cell("U1").Value = careTeamSurvey.Question3Why.QuestionText; #endregion #region Rows // write some values into column 2 worksheet.Cell("A2").Value = "Care Team"; worksheet.Cell("B2").Value = hospitalDetails.RegionName; worksheet.Cell("C2").Value = careTeamSurvey.Survey.FacilityName; worksheet.Cell("D2").Value = hospitalDetails.SiteNumber; worksheet.Cell("E2").Value = DateTime.Now.ToString("MM/dd/yyyy"); worksheet.Cell("F2").Value = careTeamSurvey.Question3A.Response; worksheet.Cell("G2").Value = careTeamSurvey.Question3B.Response; worksheet.Cell("H2").Value = careTeamSurvey.Question3C.Response; worksheet.Cell("I2").Value = careTeamSurvey.Question3D.Response; worksheet.Cell("J2").Value = careTeamSurvey.Question3E.Response; worksheet.Cell("K2").Value = careTeamSurvey.Question3F.Response; worksheet.Cell("L2").Value = careTeamSurvey.Question3G.Response; worksheet.Cell("M2").Value = careTeamSurvey.Question3H.Response; worksheet.Cell("N2").Value = careTeamSurvey.Question3I.Response; worksheet.Cell("O2").Value = careTeamSurvey.Question3J.Response; worksheet.Cell("P2").Value = careTeamSurvey.Question3K.Response; worksheet.Cell("Q2").Value = careTeamSurvey.Question3L.Response; worksheet.Cell("R2").Value = careTeamSurvey.Question3M.Response; worksheet.Cell("S2").Value = careTeamSurvey.Question3N.Response; worksheet.Cell("T2").Value = careTeamSurvey.Question3O.Response; worksheet.Cell("U2").Value = careTeamSurvey.Question3Why.Response; #endregion workbook.SaveAs(fileName); var bytes = System.IO.File.ReadAllBytes(fileName); System.IO.FileInfo newFile = new System.IO.FileInfo(fileName); if (newFile.Exists) newFile.Delete(); return bytes; }
public byte[] GetDataToExportPCPSurvey(PCPSurvey pcpSurvey, HospitalDetailsDto hospitalDetails) { string fileName = @"C:\Escalation_PCP_Report_" + Guid.NewGuid() + ".xlsx"; var configureCells = new ConfigureEscalationReport(); var workbook = new XLWorkbook(); var worksheet = workbook.Worksheets.Add("Survey Escalation Report"); configureCells.ConfigureCell(worksheet, pcpSurvey.Survey.SurveyType); #region Headers worksheet.Cell("A1").Value = "Survey Type"; worksheet.Cell("B1").Value = "Region"; worksheet.Cell("C1").Value = "Site"; worksheet.Cell("D1").Value = "Site #"; worksheet.Cell("E1").Value = "Provider Last Name"; worksheet.Cell("F1").Value = "Provider First Name"; worksheet.Cell("G1").Value = "Date of Survey"; worksheet.Cell("H1").Value = pcpSurvey.Question2A.QuestionText; worksheet.Cell("I1").Value = pcpSurvey.Question2B.QuestionText; worksheet.Cell("J1").Value = pcpSurvey.Question2C.QuestionText; worksheet.Cell("K1").Value = pcpSurvey.Question2D.QuestionText; worksheet.Cell("L1").Value = pcpSurvey.Question2E.QuestionText; worksheet.Cell("M1").Value = pcpSurvey.Question2F.QuestionText; worksheet.Cell("N1").Value = pcpSurvey.Question2G.QuestionText; worksheet.Cell("O1").Value = pcpSurvey.Question2H.QuestionText; worksheet.Cell("P1").Value = pcpSurvey.Question2Why.QuestionText; #endregion #region Rows // write some values into column 2 worksheet.Cell("A2").Value = "PCP"; worksheet.Cell("B2").Value = hospitalDetails.RegionName; worksheet.Cell("C2").Value = pcpSurvey.Survey.FacilityName; worksheet.Cell("D2").Value = hospitalDetails.SiteNumber; worksheet.Cell("E2").Value = pcpSurvey.Survey.ProviderLastName; worksheet.Cell("F2").Value = pcpSurvey.Survey.ProviderFirstName; worksheet.Cell("G2").Value = DateTime.Now.ToString("MM/dd/yyyy"); worksheet.Cell("H2").Value = pcpSurvey.Question2A.Response; worksheet.Cell("I2").Value = pcpSurvey.Question2B.Response; worksheet.Cell("J2").Value = pcpSurvey.Question2C.Response; worksheet.Cell("K2").Value = pcpSurvey.Question2D.Response; worksheet.Cell("L2").Value = pcpSurvey.Question2E.Response; worksheet.Cell("M2").Value = pcpSurvey.Question2F.Response; worksheet.Cell("N2").Value = pcpSurvey.Question2G.Response; worksheet.Cell("O2").Value = pcpSurvey.Question2H.Response; worksheet.Cell("P2").Value = pcpSurvey.Question2Why.Response; #endregion workbook.SaveAs(fileName); var bytes = System.IO.File.ReadAllBytes(fileName); System.IO.FileInfo newFile = new System.IO.FileInfo(fileName); if (newFile.Exists) newFile.Delete(); return bytes; }