public async Task <byte[]> ExportResult(LoadResult lr, string format)
        {
            XtraReport report     = new XtraReport();
            var        loadedData = lr;

            report.DataSource = loadedData.data.Cast <Products>();
            CreateReport(report, new string[] { "ProductName", "CategoryId", "UnitPrice", "UnitsInStock", "UnitsOnOrder", "Discontinued" });
            return(await new TaskFactory().StartNew(() => {
                report.CreateDocument();
                using (MemoryStream fs = new MemoryStream()) {
                    if (format == pdf)
                    {
                        report.ExportToPdf(fs);
                    }
                    else if (format == xlsx)
                    {
                        report.ExportToXlsx(fs);
                    }
                    else if (format == docx)
                    {
                        report.ExportToDocx(fs);
                    }
                    return fs.ToArray();
                }
            }));
        }
        public static bool ExportExcelByPath(XtraReport report, string filePath, string sheetName, bool hasOpened = true)
        {
            try
            {
                if (report == null)
                {
                    return(false);
                }

                XlsxExportOptions xlsxExportOptions = new XlsxExportOptions
                {
                    SheetName = sheetName
                };

                if (report.Parameters[ExcelParam] != null)
                {
                    report.Parameters[ExcelParam].Value = true;
                }

                report.ExportToXlsx(filePath, xlsxExportOptions);

                if (hasOpened)
                {
                    System.Diagnostics.Process.Start(filePath);
                }

                return(true);
            }
            catch (Exception ex)
            {
                BSLog.Logger.Warn(ex.Message);
                MessageBoxHelper.ShowErrorMessage($"Xuất excel thất bại!\r\n{ex.Message}");
                return(false);
            }
        }
示例#3
0
        private async Task ExportResult(string format, DataSourceLoadOptionsBase dataOptions, HttpContext context)
        {
            XtraReport report = new XtraReport();

            dataOptions.Skip = 0;
            dataOptions.Take = 0;
            var loadedData = DataSourceLoader.Load(await weatherForecastService.GetForecastAsync(), dataOptions);

            report.DataSource = loadedData.data.Cast <WeatherForecast>();
            ReportHelper.CreateReport(report, new string[] { "TemperatureC", "TemperatureF", "Summary", "Date" });
            await new TaskFactory().StartNew(() => {
                report.CreateDocument();
                using (MemoryStream fs = new MemoryStream()) {
                    if (format == pdf)
                    {
                        report.ExportToPdf(fs);
                    }
                    else if (format == xlsx)
                    {
                        report.ExportToXlsx(fs);
                    }
                    else if (format == docx)
                    {
                        report.ExportToDocx(fs);
                    }
                    context.Response.Clear();
                    context.Response.Headers.Append("Content-Type", "application/" + format);
                    context.Response.Headers.Append("Content-Transfer-Encoding", "binary");
                    context.Response.Headers.Append("Content-Disposition", "attachment; filename=ExportedDocument." + format);
                    context.Response.Body.WriteAsync(fs.ToArray(), 0, fs.ToArray().Length);
                    return(context.Response.CompleteAsync());
                }
            });
        }
        public static void ExportExcel(string reportID,
                                       object dataSource,
                                       List <ReportParam> reportParams,
                                       bool hasOpened         = true,
                                       bool isUseParramCommon = true,
                                       string sheetName       = null)
        {
            string templateName = ReportTemplate.GetTemplate(reportID);

            SaveFileDialog openFileDialog = new SaveFileDialog
            {
                Filter   = "Excel file(*.xlsx)|*.xlsx",
                FileName = templateName
            };

            string path;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                path = openFileDialog.FileName;
            }
            else
            {
                return;
            }

            try
            {
                XlsxExportOptions xlsxExportOptions = new XlsxExportOptions
                {
                    SheetName = string.IsNullOrWhiteSpace(sheetName) ? templateName : sheetName
                };

                reportParams.Add(new ReportParam(ExcelParam, true));

                XtraReport report = GetReport(reportID, dataSource, reportParams, isUseParramCommon);
                if (report == null)
                {
                    return;
                }

                report.ExportToXlsx(path, xlsxExportOptions);

                if (hasOpened)
                {
                    System.Diagnostics.Process.Start(path);
                }
            }
            catch (Exception ex)
            {
                BSLog.Logger.Warn(ex.Message);
                MessageBoxHelper.ShowErrorMessage($"Xuất excel thất bại!\r\n{ex.Message}");
            }
        }
示例#5
0
 private void btnExport_Click(object sender, EventArgs e)
 {
     using (var saveFileDialog = new SaveFileDialog())
     {
         saveFileDialog.AddExtension = true;
         saveFileDialog.DefaultExt   = ".xlsx";
         if (saveFileDialog.ShowDialog(this) != DialogResult.Cancel)
         {
             report.ExportToXlsx(saveFileDialog.FileName);
         }
     }
 }
        public static void ExportExcel(XtraReport report, string reportID, bool hasOpened = true)
        {
            string templateName = ReportTemplate.GetTemplate(reportID);

            SaveFileDialog openFileDialog = new SaveFileDialog
            {
                Filter   = "Excel file(*.xlsx)|*.xlsx",
                FileName = templateName
            };

            string path;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                path = openFileDialog.FileName;
            }
            else
            {
                return;
            }

            try
            {
                XlsxExportOptions xlsxExportOptions = new XlsxExportOptions
                {
                    SheetName = templateName
                };

                if (report == null)
                {
                    return;
                }

                if (report.Parameters[ExcelParam] != null)
                {
                    report.Parameters[ExcelParam].Value = true;
                }

                report.ExportToXlsx(path, xlsxExportOptions);

                if (hasOpened)
                {
                    System.Diagnostics.Process.Start(path);
                }
            }
            catch (Exception ex)
            {
                BSLog.Logger.Warn(ex.Message);
                MessageBoxHelper.ShowErrorMessage($"Xuất excel thất bại!\r\n{ex.Message}");
            }
        }
示例#7
0
        public void ExportReport(XtraReport report, string fileName, bool saveAsFile, string fileFormat)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                report.ExportToXlsx(stream);

                string disposition = saveAsFile ? "attachment" : "inline";

                Response.Clear();
                Response.Buffer = false;
                Response.AppendHeader("Content-Type", string.Format("application/{0}", fileFormat));
                Response.AppendHeader("Content-Transfer-Encoding", "binary");
                Response.AppendHeader("Content-Disposition", string.Format("{0}; filename={1}.{2}", disposition, HttpUtility.UrlEncode(fileName).Replace("+", "%20"), fileFormat));
                Response.BinaryWrite(stream.ToArray());
                Response.End();
            }
        }
示例#8
0
 public void ExportRportData(DoSoEmail email, XtraReport report)
 {
     if (email.ExportFileFormat == ReportExportFileFormatEnum.HTML)
     {
         report.ExportToHtml(Path.Combine(email.FolderPath, "HtmlContent"));
     }
     if (email.ExportFileFormat == ReportExportFileFormatEnum.PDF)
     {
         var filePath = Path.Combine(email.FolderPath, HS.MyTempName + ".Pdf");
         report.ExportToPdf(filePath);
         email.SourceFilePath += filePath + ";";
     }
     if (email.ExportFileFormat == ReportExportFileFormatEnum.Xlsx)
     {
         var filePath = Path.Combine(email.FolderPath, HS.MyTempName + ".Xlsx");
         report.ExportToXlsx(filePath);
         email.SourceFilePath += filePath + ";";
     }
 }
        private void exportFileXlsx(XtraReport report)
        {
            string         reportPath = "";
            SaveFileDialog sf         = new SaveFileDialog();

            sf.FileName = "Save Here.xlsx";
            if (sf.ShowDialog() == DialogResult.OK)
            {
                reportPath = Path.GetDirectoryName(sf.FileName) + sf.FileName;
                try
                {
                    report.ExportToXlsx(sf.FileName);
                    MessageBox.Show("Lưu thành công!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
示例#10
0
        private void SavePDFReport(XtraReport xtraReport, string docName)
        {
            // To show the report designer. You need to uncomment this to design the report.
            bool designMode = false;

            if (designMode)
            {
                xtraReport.ShowDesigner();
                //report1.ShowPreview();
            }
            else
            {
                //Save the report in a pdf format
                xtraReport.ExportToPdf(docName);
                //EPS report in Excel format
                if (comboBoxChooseReport.Text == "EPS Report")
                {
                    docName = docName.Replace("pdf", "xlsx");
                    xtraReport.ExportToXlsx(docName);
                }
            }
        }
示例#11
0
        protected void comboReports_SelectedIndexChanged(object sender, EventArgs e)
        {
            var SelectedReport = comboReports.Value.ToString();

            if (SelectedReport == "rep_pro_essa")
            {
                MemoryStream reportStream1 = new MemoryStream();
                MemoryStream reportStream2 = new MemoryStream();
                MemoryStream reportStream3 = new MemoryStream();
                MemoryStream reportStream4 = new MemoryStream();

                XtraReport ReportObject1 = common_services.GetSourcedReport("rep_pro_essa1");
                ReportObject1.ExportToXlsx(reportStream1, new DevExpress.XtraPrinting.XlsxExportOptions()
                {
                    SheetName = "BA-Scorecard"
                });

                XtraReport ReportObject2 = common_services.GetSourcedReport("rep_pro_essa2");
                ReportObject2.ExportToXlsx(reportStream2, new DevExpress.XtraPrinting.XlsxExportOptions()
                {
                    SheetName = "IA-Scorecard"
                });

                XtraReport ReportObject3 = common_services.GetSourcedReport("rep_pro_essa3");
                ReportObject3.ExportToXlsx(reportStream3, new DevExpress.XtraPrinting.XlsxExportOptions()
                {
                    SheetName = "TA-Scorecard"
                });

                XtraReport ReportObject4 = common_services.GetSourcedReport("rep_pro_essa4");
                ReportObject4.ExportToXlsx(reportStream4, new DevExpress.XtraPrinting.XlsxExportOptions()
                {
                    SheetName = "S&C Scorecard"
                });

                Workbook workbook = new DevExpress.Spreadsheet.Workbook();
                workbook.LoadDocument(reportStream1);

                Workbook workbook2 = new DevExpress.Spreadsheet.Workbook();
                workbook2.LoadDocument(reportStream2);

                Workbook workbook3 = new DevExpress.Spreadsheet.Workbook();
                workbook3.LoadDocument(reportStream3);

                Workbook workbook4 = new DevExpress.Spreadsheet.Workbook();
                workbook4.LoadDocument(reportStream4);

                workbook.Worksheets.Insert(1, "IA-Scorecard");
                workbook.Worksheets.Insert(2, "TA-Scorecard");
                workbook.Worksheets.Insert(3, "S&C Scorecard");
                workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);
                workbook.Worksheets[3].CopyFrom(workbook4.Worksheets[0]);

                MemoryStream st = new MemoryStream();
                workbook.SaveDocument(st, DocumentFormat.Xlsx);

                Response.Clear();
                Response.ContentType = "application/force-download";
                Response.AddHeader("content-disposition", "attachment; filename=Scorecard_Templates_Ohio2015SS-A.xlsx");
                Response.BinaryWrite(st.ToArray());
                Response.End();

                reportViewer.OpenReport(ReportObject1);
            }
            else if (SelectedReport == "rep_pro_cms_checlist")
            {
                var projectId = System.Web.HttpContext.Current.Session["projectID"].ToString();

                comboChecklistName.DataSource = rtm_services.GetRTMCheckList(projectId);
                comboChecklistName.DataBind();
                comboChecklistName.Visible = true;
            }


            else
            {
                comboChecklistName.Visible = false;
                comboChecklistName.Value   = null;
                XtraReport ReportObject = common_services.GetSourcedReport(SelectedReport, null, null, null, Page.Request);

                reportViewer.OpenReport(ReportObject);
            }
        }
示例#12
0
        protected void comboChecklistName_SelectedIndexChanged(object sender, EventArgs e)
        {
            string path         = null;
            string guidancepath = null;
            string MITApath     = null;
            string report       = comboReports.SelectedItem.ToString();
            string reportname   = comboReports.Value.ToString();

            if (reportname == "rep_pro_cms_checlist")
            {
                string       SelectedChecklisID = comboChecklistName.Value.ToString();
                string       SelecteChecklist   = comboChecklistName.Text.ToString();
                string       checklist          = SelectedChecklisID;
                MemoryStream reportStream5      = new MemoryStream();
                MemoryStream reportStream6      = new MemoryStream();
                //MemoryStream reportStream7 = new MemoryStream();
                //MemoryStream reportStream8 = new MemoryStream();

                XtraReport ReportObject1 = common_services.GetSourcedReport("rep_pro_cms_checlist", checklist);
                ReportObject1.ExportToXlsx(reportStream5, new DevExpress.XtraPrinting.XlsxExportOptions()
                {
                    SheetName = SelecteChecklist
                });

                XtraReport ReportObject2 = common_services.GetSourcedReport("rep_pro_cms_checklist_criticalsuccessfactors", checklist);
                ReportObject2.ExportToXlsx(reportStream6, new DevExpress.XtraPrinting.XlsxExportOptions()
                {
                    SheetName = "Critical Success Factor"
                });

                Workbook workbook  = new DevExpress.Spreadsheet.Workbook();
                Workbook workbook2 = new DevExpress.Spreadsheet.Workbook();
                Workbook workbook3 = new DevExpress.Spreadsheet.Workbook();
                Workbook workbook4 = new DevExpress.Spreadsheet.Workbook();
                Workbook workbook5 = new DevExpress.Spreadsheet.Workbook();

                switch (SelecteChecklist)
                {
                case "Provider Management":
                    path = Server.MapPath(@"~/Content/SpreadSheetTemplate/Provider Management Checklist.xlsx");

                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(reportStream6);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "Critical Success Factor");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);

                    break;

                case "2.2 Standards and Conditions":
                    path         = Server.MapPath(@"~/Content/SpreadSheetTemplate/Standards and Conditions.xlsx");
                    guidancepath = Server.MapPath("~/Content/SpreadSheetTemplate/Guidance Standards and Conditions.xlsx");
                    MITApath     = Server.MapPath("~/Content/SpreadSheetTemplate/MITA Business Process Access and Delivery.xlsx");

                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(guidancepath);
                    workbook4.LoadDocument(MITApath);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "MITA Business Processes");
                    workbook.Worksheets.Insert(3, "Guidance");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);
                    workbook.Worksheets[3].CopyFrom(workbook4.Worksheets[0]);

                    break;

                case "Integration and Utility":
                    path         = Server.MapPath(@"~/Content/SpreadSheetTemplate/Integration and Utility.xlsx");
                    guidancepath = Server.MapPath("~/Content/SpreadSheetTemplate/Guidance Integration and Utility.xlsx");
                    MITApath     = Server.MapPath("~/Content/SpreadSheetTemplate/MITA Business Process Access and Delivery.xlsx");
                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(guidancepath);
                    workbook4.LoadDocument(MITApath);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "MITA Business Processes");
                    workbook.Worksheets.Insert(3, "Guidance");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);
                    workbook.Worksheets[3].CopyFrom(workbook4.Worksheets[0]);
                    break;

                case "Plan Management":
                    path = Server.MapPath(@"~/Content/SpreadSheetTemplate/Plan Management.xlsx");

                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(reportStream6);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "Critical Success Factor");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);

                    break;

                case "Information Architecture":
                    path         = Server.MapPath(@"~/Content/SpreadSheetTemplate/Information Architure Checklist.xlsx");
                    guidancepath = Server.MapPath("~/Content/SpreadSheetTemplate/Guidance Inforamtion Achitecture.xlsx");
                    MITApath     = Server.MapPath("~/Content/SpreadSheetTemplate/MITA Business Process Access and Delivery.xlsx");
                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(guidancepath);
                    workbook4.LoadDocument(MITApath);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "MITA Business Processes");
                    workbook.Worksheets.Insert(3, "Guidance");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);
                    workbook.Worksheets[3].CopyFrom(workbook4.Worksheets[0]);

                    break;

                case "Contractor Management":
                    path = Server.MapPath(@"~/Content/SpreadSheetTemplate/Contractor Management Checklist.xlsx");
                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(reportStream6);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "Critical Success Factor");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);

                    break;

                case "Member Management":
                    path = Server.MapPath(@"~/Content/SpreadSheetTemplate/Member Management.xlsx");
                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(reportStream6);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "Critical Success Factor");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);

                    break;

                case "Care Management":
                    path = Server.MapPath(@"~/Content/SpreadSheetTemplate/CMS_CareManagement.xlsx");
                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(reportStream6);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "Critical Success Factor");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);

                    break;

                case "Operations Management":
                    path = Server.MapPath(@"~/Content/SpreadSheetTemplate/Operations Management.xlsx");
                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(reportStream6);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "Critical Success Factor");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);

                    break;

                case "Financial Management":
                    path = Server.MapPath(@"~/Content/SpreadSheetTemplate/Financial Management Checklist.xlsx");
                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(reportStream6);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "Critical Success Factor");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);

                    break;

                case "Access and Delivery":
                    path         = Server.MapPath(@"~/Content/SpreadSheetTemplate/Access and Delivery Checklist.xlsx");
                    guidancepath = Server.MapPath("~/Content/SpreadSheetTemplate/Guidance Access and Delivery.xlsx");
                    MITApath     = Server.MapPath("~/Content/SpreadSheetTemplate/MITA Business Process Access and Delivery.xlsx");
                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(guidancepath);
                    workbook4.LoadDocument(MITApath);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "MITA Business Processes");
                    workbook.Worksheets.Insert(3, "Guidance");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);
                    workbook.Worksheets[3].CopyFrom(workbook4.Worksheets[0]);
                    break;

                case "Intermediary and Interface":
                    path         = Server.MapPath(@"~/Content/SpreadSheetTemplate/Intermediary and Interface.xlsx");
                    guidancepath = Server.MapPath("~/Content/SpreadSheetTemplate/Guidance Intermediary and Interface.xlsx");
                    MITApath     = Server.MapPath("~/Content/SpreadSheetTemplate/MITA Business Process Access and Delivery.xlsx");
                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(guidancepath);
                    workbook4.LoadDocument(MITApath);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "MITA Business Processes");
                    workbook.Worksheets.Insert(3, "Guidance");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);
                    workbook.Worksheets[3].CopyFrom(workbook4.Worksheets[0]);
                    break;

                case "Performance Management":
                    path = Server.MapPath(@"~/Content/SpreadSheetTemplate/Performance Management.xlsx");
                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(reportStream6);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "Critical Success Factor");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);

                    break;

                case "Standards and Conditions":
                    path         = Server.MapPath(@"~/Content/SpreadSheetTemplate/Standards and Conditions.xlsx");
                    guidancepath = Server.MapPath("~/Content/SpreadSheetTemplate/Guidance Standards and Conditions.xlsx");
                    MITApath     = Server.MapPath("~/Content/SpreadSheetTemplate/MITA Business Process Access and Delivery.xlsx");
                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(guidancepath);
                    workbook4.LoadDocument(MITApath);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "MITA Business Processes");
                    workbook.Worksheets.Insert(3, "Guidance");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);
                    workbook.Worksheets[3].CopyFrom(workbook4.Worksheets[0]);

                    break;

                case "Eligibility and Enrollment":
                    path = Server.MapPath(@"~/Content/SpreadSheetTemplate/Eligibility and Enrollment Management.xlsx");
                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(reportStream6);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "Critical Success Factor");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);
                    break;

                case "Business Relationship Management":
                    path = Server.MapPath(@"~/Content/SpreadSheetTemplate/Eligibility and Enrollment Management.xlsx");
                    workbook.LoadDocument(path);
                    workbook2.LoadDocument(reportStream5);
                    workbook3.LoadDocument(reportStream6);
                    workbook.Worksheets.Insert(1, SelecteChecklist);
                    workbook.Worksheets.Insert(2, "Critical Success Factor");

                    workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                    workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);


                    break;
                }



                MemoryStream st = new MemoryStream();
                workbook.SaveDocument(st, DocumentFormat.Xlsx);
                var    state    = System.Web.HttpContext.Current.Session["EnterpriseName"].ToString();
                string filename = SelecteChecklist + " Checklist (MITA Module)" + state + ".xlsx";
                Response.Clear();
                Response.ContentType = "application/force-download";
                Response.AddHeader("content-disposition", "attachment; filename=" + filename);
                Response.BinaryWrite(st.ToArray());


                Response.End();
                reportViewer.OpenReport(ReportObject1);
            }
            else
            {
                comboChecklistName.Visible = false;
                comboChecklistName.Value   = null;
            }
        }
示例#13
0
        protected void comboIVV_SelectedIndexChanged(object sender, EventArgs e)
        {
            string SelectedReport = comboReports.Value.ToString();

            if (SelectedReport == "rep_pro_ivv_progress")
            {
                string SelectedID       = comboIVV.Value.ToString();
                string SelecteChecklist = comboIVV.Text.ToString();
                string StateProject     = SelectedID;



                MemoryStream reportStream1 = new MemoryStream();
                MemoryStream reportStream2 = new MemoryStream();

                XtraReport ReportObject1 = common_services.GetSourcedReport("rep_pro_ivv_progress", StateProject);
                ReportObject1.ExportToXlsx(reportStream1, new DevExpress.XtraPrinting.XlsxExportOptions()
                {
                    SheetName = "IV&V"
                });

                XtraReport ReportObject2 = common_services.GetSourcedReport("rep_pro_ivv_checklist_rtm");
                ReportObject2.ExportToXlsx(reportStream2, new DevExpress.XtraPrinting.XlsxExportOptions()
                {
                    SheetName = "Programmatic"
                });

                Workbook workbook = new DevExpress.Spreadsheet.Workbook();
                workbook.LoadDocument(reportStream1);

                Workbook workbook2 = new DevExpress.Spreadsheet.Workbook();
                workbook2.LoadDocument(reportStream2);

                var      path      = Server.MapPath(@"~/Content/SpreadSheetTemplate/IVV CMS Response.xlsx");
                Workbook workbook3 = new DevExpress.Spreadsheet.Workbook();
                workbook3.LoadDocument(path);



                workbook.Worksheets.Insert(1, "Programmatic");
                workbook.Worksheets.Insert(2, "CMS Response");

                workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
                workbook.Worksheets[2].CopyFrom(workbook3.Worksheets[0]);


                MemoryStream st = new MemoryStream();
                workbook.SaveDocument(st, DocumentFormat.Xlsx);
                var    state    = System.Web.HttpContext.Current.Session["EnterpriseName"].ToString();
                string filename = " 05 MECT 2_2 Appendix D_MMIS IVV Progress Report Template.xlsx";
                Response.Clear();
                Response.ContentType = "application/force-download";
                Response.AddHeader("content-disposition", "attachment; filename=" + filename);
                Response.BinaryWrite(st.ToArray());


                Response.End();

                reportViewer.OpenReport(ReportObject1);
            }

            else
            {
                comboIVV.Visible = false;
                comboIVV.Value   = null;
            }
        }
        private void PrintReport(ReportParametersObjectBase GetReportParametersObject)
        {
            var fileName = String.Empty;

            ProcessedfileNameAddress = String.Empty;
            try
            {
                using (SaveFileDialog sfd = new SaveFileDialog())
                {
                    var agora = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
                    fileName = $"{currentReport.DisplayName} {agora}";

                    sfd.FileName = fileName;
                    sfd.Filter   = "Formato Excel (*.xlsx)|*.xlsx";

                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        CriteriaOperator filter = string.Empty;
                        if (GetReportParametersObject != null)
                        {
                            filter = XpoObjectInCriteriaProcessingHelper.ParseCriteria(((XPObjectSpace)ObjectSpace).Session, GetReportParametersObject?.GetCriteria()?.LegacyToString());
                        }
                        else
                        {
                            filter = string.Empty;
                        }

                        var sorting = GetReportParametersObject?.GetSorting();

                        XtraReport      report        = ReportDataProvider.ReportsStorage.LoadReport(currentReport);
                        ReportsModuleV2 reportsModule = ReportsModuleV2.FindReportsModule(Application.Modules);

                        if (reportsModule != null && reportsModule.ReportsDataSourceHelper != null)
                        {
                            if (GetReportParametersObject == null)
                            {
                                reportsModule.ReportsDataSourceHelper.SetupBeforePrint(report, null, null, true, null, true);
                            }
                            else
                            {
                                reportsModule.ReportsDataSourceHelper.SetupBeforePrint(report, null, filter, true, sorting, true);
                            }

                            XtraForm form = new XtraForm()
                            {
                                FormBorderStyle = FormBorderStyle.None,
                                Size            = new System.Drawing.Size(400, 20),
                                ShowInTaskbar   = false,
                                StartPosition   = FormStartPosition.CenterScreen,
                                TopMost         = true
                            };

                            ProgressBarControl progressBar  = new ProgressBarControl();
                            ReflectorBar       reflectorBar = new ReflectorBar(progressBar);

                            form.Controls.Add(progressBar);
                            progressBar.Dock = DockStyle.Fill;

                            XlsxExportOptions options = new XlsxExportOptions {
                                ExportMode = XlsxExportMode.SingleFile, ShowGridLines = true, RawDataMode = false
                            };

                            form.Show();
                            report.PrintingSystem.ProgressReflector = reflectorBar;
                            report.ExportToXlsx(sfd.FileName, options);
                            report.PrintingSystem.ResetProgressReflector();
                            form.Close();
                            form.Dispose();
                            ProcessedfileNameAddress = sfd.FileName;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }

            if (!String.IsNullOrEmpty(ProcessedfileNameAddress))
            {
                FileInfo fi = new FileInfo(ProcessedfileNameAddress);
                if (fi.Exists)
                {
                    Form      mainForm = (Form)Application.MainWindow.Template;
                    AlertInfo info     = new AlertInfo("Processo Finalizado!", $"{fileName} (Clique aqui para abrir");
                    alertControlCore.Show(mainForm, info);
                }
            }
        }