如何不显示C#中的PrintDialog()而直接打印rdlc报告? [英] How to directly print rdlc report without showing PrintDialog() in C#?
本文介绍了如何不显示C#中的PrintDialog()而直接打印rdlc报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个应用程序,必须打印 RDLC
报告,而不显示printDialog并使用应用程序中定义的默认指定打印机。下面是我的测试实现代码。
I have an application where I have to print a RDLC
report without showing the printDialog and using the default specified printer defined in the application. Below is my test implementaion code.
Microsoft.Reporting.WinForms.ReportViewer reportViewerSales = new Microsoft.Reporting.WinForms.ReportViewer();
Microsoft.Reporting.WinForms.ReportDataSource reportDataSourceSales = new Microsoft.Reporting.WinForms.ReportDataSource();
reportViewerSales.Reset();
reportViewerSales.LocalReport.ReportPath = @"Sales.rdlc";
reportDataSourceSales.Name = "SalesTableDataSet";
int i = 1;
foreach (Product item in ProductSalesList)
{
dataset.CurrentSales.AddCurrentSalesRow(i, item.Name, item.Quantity.ToString(), item.Price.ToString(), item.Price.ToString());
i++;
}
reportDataSourceSales.Value = dataset.CurrentSales;
reportViewerSales.LocalReport.DataSources.Add(reportDataSourceSales);
dataset.EndInit();
reportViewerSales.RefreshReport();
reportViewerSales.RenderingComplete += new RenderingCompleteEventHandler(PrintSales);
这是我的渲染完成方法
public void PrintSales(object sender, RenderingCompleteEventArgs e)
{
try
{
reportViewerSales.PrintDialog();
reportViewerSales.Clear();
reportViewerSales.LocalReport.ReleaseSandboxAppDomain();
}
catch (Exception ex)
{
}
}
推荐答案
我只是快速浏览了我创建的要直接打印的类,我想我从本演练中学到了一些想法:
在不预览的情况下打印本地报告
I just gave a quick look to a class I created to print directly and I think I took some ideas from this walkthrough: Printing a Local Report without Preview
这篇关于如何不显示C#中的PrintDialog()而直接打印rdlc报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文