private void Form1_Load(object sender, EventArgs e) { // Create a report and make it // a document source of the document viewer. report = new XtraReport1(); documentViewer1.DocumentSource = report; // Create a form to show a progress bar, // and adjust its properties. Form form = new Form() { FormBorderStyle = FormBorderStyle.None, Size = new System.Drawing.Size(300, 25), ShowInTaskbar = false, StartPosition = FormStartPosition.CenterScreen, TopMost = true }; // Create a ProgressBar along with its ReflectorBar. ProgressBarControl progressBar = new ProgressBarControl(); ReflectorBar reflectorBar = new ReflectorBar(progressBar); // Add a progress bar to a form and show it. form.Controls.Add(progressBar); progressBar.Dock = DockStyle.Fill; form.Show(); try { // Register the reflector bar, so that it reflects // the state of a ProgressReflector. report.PrintingSystem.ProgressReflector = reflectorBar; report.CreateDocument(); } finally { // Unregister the reflector bar, so that it no longer // reflects the state of a ProgressReflector. report.PrintingSystem.ResetProgressReflector(); form.Close(); form.Dispose(); } }
//http://documentation.devexpress.com/#corelibraries/clsDevExpressXtraPrintingProgressReflectortopic public static void ShowPreview(XtraReport report) { // Create a form to show a progress bar, // and adjust its properties. Form form = new Form(); form.FormBorderStyle = FormBorderStyle.None; form.Size = new System.Drawing.Size(300, 25); form.ShowInTaskbar = false; form.StartPosition = FormStartPosition.CenterScreen; form.TopMost = true; // Create a ProgressBar along with its ReflectorBar. ProgressBarControl progressBar = new ProgressBarControl(); ReflectorBar reflectorBar = new ReflectorBar(progressBar); // Add a progress bar to a form and show it. form.Controls.Add(progressBar); progressBar.Dock = DockStyle.Fill; form.Show(); try { // Register the reflector bar, so that it reflects // the state of a ProgressReflector. report.PrintingSystem.ProgressReflector = reflectorBar; report.CreateDocument(); } finally { // Unregister the reflector bar, so that it no longer // reflects the state of a ProgressReflector. report.PrintingSystem.ResetProgressReflector(); form.Close(); form.Dispose(); } // Show the preview of the created document. report.ShowPreviewDialog(); }
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); } } }