private void reportViewer1_ReportExport(object sender, ReportExportEventArgs e) { if (e.Extension.LocalizedName != "PDF") { e.Cancel = true; } }
public static void ReportExport(object sender, ReportExportEventArgs e, ReportViewer ReportViewer1) { if (e.Extension.Name == "EXCELOPENXML") { e.Cancel = true; string mimeType; string encoding; string fileNameExtension; string[] streams; Microsoft.Reporting.WinForms.Warning[] warnings; byte[] pdfContent = ReportViewer1.LocalReport.Render("EXCEL", null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); string pdfPath = Application.StartupPath + "\\" + my.Login + "reportBarcode.xls"; try { System.IO.FileStream pdfFile = new System.IO.FileStream(pdfPath, System.IO.FileMode.Create); pdfFile.Write(pdfContent, 0, pdfContent.Length); pdfFile.Close(); System.Diagnostics.Process.Start(pdfPath); } catch (Exception ex) { MessageBox.Show(@"У Вас открыт файл предыдущего экспорта в Excel. Закройте или переименуйте его!" + ex.Message); } } ; }
/// <summary> /// Exports the report. /// </summary> /// <param name="viewer">The viewer.</param> /// <param name="index"> /// The index. /// 0 ---> doc /// 1 ---> xls /// 2 ---> pdf /// </param> /// <returns></returns> /// internal static bool ExportReport(ReportViewer viewer, ExportType index) { if (viewer.LocalReport.DataSources.Count == 0) { return(false); } Type t = viewer.GetType(); RenderingExtension re = null; RenderingExtension[] extensionArray = viewer.LocalReport.ListRenderingExtensions(); try { re = extensionArray[(int)index]; if (re != null) { ReportExportEventArgs e = new ReportExportEventArgs(re); string methodName = "OnExport"; t.InvokeMember(methodName, flags | BindingFlags.InvokeMethod, null, viewer, new object[] { null, e }); return(true); } else { return(false); } } catch { return(false); } }
private void reportViewer1_ReportExport(object sender, ReportExportEventArgs e) { if (!this.EnabledExport) { e.Cancel = true; MyMessageBox.Show("您没权限或系统不允许导出。"); } }
private void reportViewer1_ReportExport(object sender, ReportExportEventArgs e) { //cancel the default process e.Cancel = true; //the dropdown menu wasn't hiding itself //so this hack was needed to hide the menu //find the export button ToolStrip toolStrip = (ToolStrip)reportViewer1.Controls.Find("toolStrip1", true)[0]; ToolStripDropDownButton exportButton = (ToolStripDropDownButton)toolStrip.Items["export"]; exportButton.DropDown.Close(); reportViewer1.Cursor = Cursors.WaitCursor; //and run our own code to export ExportReportAction action = new ExportReportAction(e.Extension.Name, ref reportViewer1); new ActionProgressDialog(action, ProgressBarStyle.Marquee).ShowDialog(); //ReportExporterDelgate exp = new ReportExporterDelgate(RunExportReport); //IAsyncResult result = exp.BeginInvoke(e.Extension.Name, null, null); ////new ActionProgressDialog(result, ProgressBarStyle.Marquee).ShowDialog(); //result.AsyncWaitHandle.WaitOne(); //byte[] bytes = exp.EndInvoke(result); reportViewer1.Cursor = Cursors.Default; string fileExtension = ""; if (e.Extension.Name == "Excel") fileExtension = "xls"; else if (e.Extension.Name == "PDF") fileExtension = "pdf"; SaveFileDialog sfDialog = new SaveFileDialog(); sfDialog.Filter = (fileExtension == "pdf" ? Messages.FILE_PDF + "|*.pdf|" : Messages.FILE_XLS + "|*.xls|") + Messages.FILE_ALL + "|*.*"; sfDialog.AddExtension = true; if (sfDialog.ShowDialog() == DialogResult.OK) { FileStream fs = null; try { fs = new FileStream(sfDialog.FileName, FileMode.Create); fs.Write(action.ReportData, 0, action.ReportData.Length); lblExported.Text = Messages.WLBREPORT_EXPORT_SUCC; lblExported.Visible = true; timer1.Start(); } catch (Exception ex) { log.Debug(ex, ex); new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, ex.Message, Messages.XENCENTER)).ShowDialog(this); } finally { if (fs != null) fs.Close(); } } //bytes = null; }
private void reportViewer1_ReportExport(object sender, ReportExportEventArgs e) { //cancel the default process e.Cancel = true; //the dropdown menu wasn't hiding itself //so this hack was needed to hide the menu //find the export button ToolStrip toolStrip = (ToolStrip)reportViewer1.Controls.Find("toolStrip1", true)[0]; ToolStripDropDownButton exportButton = (ToolStripDropDownButton)toolStrip.Items["export"]; exportButton.DropDown.Close(); reportViewer1.Cursor = Cursors.WaitCursor; //and run our own code to export ExportReportAction action = new ExportReportAction(e.Extension.Name, ref reportViewer1); new ActionProgressDialog(action, ProgressBarStyle.Marquee).ShowDialog(); //ReportExporterDelgate exp = new ReportExporterDelgate(RunExportReport); //IAsyncResult result = exp.BeginInvoke(e.Extension.Name, null, null); ////new ActionProgressDialog(result, ProgressBarStyle.Marquee).ShowDialog(); //result.AsyncWaitHandle.WaitOne(); //byte[] bytes = exp.EndInvoke(result); reportViewer1.Cursor = Cursors.Default; string fileExtension = ""; if (e.Extension.Name == "Excel") { fileExtension = "xls"; } else if (e.Extension.Name == "PDF") { fileExtension = "pdf"; } SaveFileDialog sfDialog = new SaveFileDialog(); sfDialog.Filter = (fileExtension == "pdf" ? Messages.FILE_PDF + "|*.pdf|" : Messages.FILE_XLS + "|*.xls|") + Messages.FILE_ALL + "|*.*"; sfDialog.AddExtension = true; if (sfDialog.ShowDialog() == DialogResult.OK) { FileStream fs = null; try { fs = new FileStream(sfDialog.FileName, FileMode.Create); fs.Write(action.ReportData, 0, action.ReportData.Length); lblExported.Text = Messages.WLBREPORT_EXPORT_SUCC; lblExported.Visible = true; timer1.Start(); } catch (Exception ex) { log.Debug(ex, ex); new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, ex.Message, Messages.XENCENTER)).ShowDialog(this); } finally { if (fs != null) { fs.Close(); } } } //bytes = null; }
private void reportViewer1_ReportExport(object sender, ReportExportEventArgs e) { Inventori.Module.ModuleControlSettings.SaveLog(ListOfAction.Export, lbl_TempReport.Text, ListOfTable.Report, lbl_UserName.Text); }
private void reportViewer1_ReportExport(object sender, ReportExportEventArgs e) { my.ReportExport(sender, e, reportViewer1); }
private void reportViewer_ReportExport(object sender, ReportExportEventArgs e) { }
void repViewer_ReportExport(object sender, ReportExportEventArgs e) { e.Cancel = true; }
private void reportViewer1_ReportExport(object sender, ReportExportEventArgs e) { ToolStrip ts = new ToolStrip(); ts.Items.Add("Email"); }