RDL 报表静默输出
请教 RDL 报表通过 IIS 部署的服务器实现静默输出的问题。项目中设计了一份 RDL 报表,需要通过部署在 Windows Server 上的 IIS 应用程序实现静默输出,在论坛的例子,用下面的代码实现了打印输出:
public static void PrintReport(linkReportPrint printSetting)
{
PageReport pageReport = ReportLoad(printSetting.ARSetting);
pageReport.Run();
//pageReport.Document.Printer.DefaultPageSettings.Margins.Bottom = 0;
//pageReport.Document.Printer.DefaultPageSettings.Margins.Left = 0;
//pageReport.Document.Printer.DefaultPageSettings.Margins.Right = 0;
//pageReport.Document.Printer.DefaultPageSettings.Margins.Top = 0;
//pageReport.Document.Printer.PaperSize.RawKind = 0;
//pageReport.Document.Printer.PaperSize.Width = 14;
//pageReport.Document.Printer.PaperSize.Height = 20;
if ((printSetting.printerName != null) && (printSetting.printerName != ""))
{
pageReport.Document.Printer.PrinterName = printSetting.printerName; // "Foxit Reader PDF Printer";
}
//pageReport.Document.Printer.PrinterSettings.Copies = 1;
//pageReport.Document.Printer.PrinterSettings.FromPage = 1;
//pageReport.Document.Printer.PrinterSettings.ToPage = 2;
//pageReport.Document.Printer.PrinterSettings.PrintRange = 0;
pageReport.Document.Print(showPrintDialog: printSetting.showPrintDialog,
showPrintProgressDialog: printSetting.showPrintProgressDialog,
usePrintingThread: true);
//pageDocument.Print(showPrintDialog: false, showPrintProgressDialog: false, usePrintingThread: false);
}
碰到的问题是,这个报表是多页的,通过预览打印没有问题,然而通过上述代码输出是打印机有多页走纸,却只打印出了第一页的内容。
请问是不是 pagereport 的这种静默输出的方式不能用于 RDL 报表?RDL 报表如何才能实现静默输出呢?
多谢!
您好,你的程序是Winform程序还是其他程序,你的报表的数据源链接使用的是数据库直连还是动态数据源绑定。你能提供 下 你的具体demo我这边进行验证看看 本帖最后由 netstone 于 2020-7-8 09:54 编辑
winform 应用程序,数据源直连数据库的。报表预览打印正常,通过 reportviewer 加载后打印也正常。 /// <summary>
/// 将报表直接打印输出
/// </summary>
/// <param name="ARSetting"></param>
/// <param name="sType"></param>
/// <param name="sFile"></param>
public static void PrintReport(linkReportPrint printSetting)
{
//public static void PrintReport(ActiveReportSetting ARSetting)
PageReport pageReport = ReportLoad(printSetting.ARSetting);
pageReport.Run();
//pageReport.Document.Printer.DefaultPageSettings.Margins.Bottom = 0;
//pageReport.Document.Printer.DefaultPageSettings.Margins.Left = 0;
//pageReport.Document.Printer.DefaultPageSettings.Margins.Right = 0;
//pageReport.Document.Printer.DefaultPageSettings.Margins.Top = 0;
//pageReport.Document.Printer.PaperSize.RawKind = 0;
//pageReport.Document.Printer.PaperSize.Width = 14;
//pageReport.Document.Printer.PaperSize.Height = 20;
if ((printSetting.printerName != null) && (printSetting.printerName != ""))
{
pageReport.Document.Printer.PrinterName = printSetting.printerName; // "Foxit Reader PDF Printer";
}
//pageReport.Document.Printer.PrinterSettings.Copies = 1;
//pageReport.Document.Printer.PrinterSettings.FromPage = 1;
//pageReport.Document.Printer.PrinterSettings.ToPage = 2;
//pageReport.Document.Printer.PrinterSettings.PrintRange = 0;
////GrapeCity.ActiveReports.PrintExtension.Print(_document, true, true);
//GrapeCity.ActiveReports.PrintExtension.Print(pageReport.Document,
// showPrintDialog: printSetting.showPrintDialog,
// showPrintProgressDialog: printSetting.showPrintProgressDialog);
pageReport.Document.Print(showPrintDialog: printSetting.showPrintDialog,
showPrintProgressDialog: printSetting.showPrintProgressDialog,
usePrintingThread: true);
}
/// <summary>
/// 根据指定的设置内容加载报表
/// </summary>
private static PageReport ReportLoad(ActiveReportSetting ARSetting)
{
string file_name = ARSetting.reportFile;
//string file_name = @"C:\TOTALLINK\REPORTS\TEST01.rdlx";
PageReport pr = new PageReport(new System.IO.FileInfo(file_name));
try
{
//处理多数据源连接字符串
for (int i = 0; i < ARSetting.connString.Length; i++)
{
if (ARSetting.connString != "" && i < pr.Report.DataSources.Count)
{
pr.Report.DataSources.ConnectionProperties.ConnectString = ARSetting.connString;
}
}
//处理参数列表
for (int i = 0; i < ARSetting.para.Length; i++)
{
if (i < pr.Report.ReportParameters.Count)
{
pr.Report.ReportParameters.DefaultValue.Values.Add(ARSetting.para);
}
}
}
catch (Exception)
{
//throw;
}
return pr;
}
上面是主要的代码,谢谢。
您好,我同事已经给你电话沟通。这个问题最好可以给一个能重现问题的步骤,不然我们这边也不知道该如何解决 本帖最后由 netstone 于 2020-7-8 14:56 编辑
尝试直接通过 winform 客户端打印,showdialog = true 正常,false 的时候没有打印输出,请问什么原因?
=false 的时候,实际没有打印输出。
你的意思就是调用Winform端的打印弹出打印窗口,打印正常,不弹出直接打印就没有打印输出是这样吗 是的。实际的环境是客户端的应用程序运行在一台服务器上,需要通过局域网的一台网络打印机输出。显示对话框的时候,打印正常,不显示对话框打印,就没有打印输出了。
打印机名是 \\bzj162\epson printer ... 这样指定的。 你好,这个问题很诡异,然后跟我同事也沟通了,你们使用的方式比较复杂。目前我们这边也没有特别好的解决方案
页:
[1]