找回密码
 立即注册

QQ登录

只需一步,快速开始

netstone

注册会员

4

主题

19

帖子

63

积分

注册会员

积分
63

微信认证勋章

最新发帖
netstone
注册会员   /  发表于:2020-7-8 08:30  /   查看:2637  /  回复:8
请教 RDL 报表通过 IIS 部署的服务器实现静默输出的问题。

项目中设计了一份 RDL 报表,需要通过部署在 Windows Server 上的 IIS 应用程序实现静默输出,在论坛的例子,用下面的代码实现了打印输出:
  1. public static void PrintReport(linkReportPrint printSetting)
  2.         {
  3. PageReport pageReport = ReportLoad(printSetting.ARSetting);
  4.             pageReport.Run();

  5.             //pageReport.Document.Printer.DefaultPageSettings.Margins.Bottom = 0;
  6.             //pageReport.Document.Printer.DefaultPageSettings.Margins.Left = 0;
  7.             //pageReport.Document.Printer.DefaultPageSettings.Margins.Right = 0;
  8.             //pageReport.Document.Printer.DefaultPageSettings.Margins.Top = 0;
  9.             //pageReport.Document.Printer.PaperSize.RawKind = 0;
  10.             //pageReport.Document.Printer.PaperSize.Width = 14;
  11.             //pageReport.Document.Printer.PaperSize.Height = 20;

  12.             if ((printSetting.printerName != null) && (printSetting.printerName != ""))
  13.             {
  14.                 pageReport.Document.Printer.PrinterName = printSetting.printerName; // "Foxit Reader PDF Printer";
  15.             }

  16.             //pageReport.Document.Printer.PrinterSettings.Copies = 1;
  17.             //pageReport.Document.Printer.PrinterSettings.FromPage = 1;
  18.             //pageReport.Document.Printer.PrinterSettings.ToPage = 2;
  19.             //pageReport.Document.Printer.PrinterSettings.PrintRange = 0;

  20. pageReport.Document.Print(showPrintDialog: printSetting.showPrintDialog,
  21.                 showPrintProgressDialog: printSetting.showPrintProgressDialog,
  22.                 usePrintingThread: true);

  23. //pageDocument.Print(showPrintDialog: false, showPrintProgressDialog: false, usePrintingThread: false);
  24. }
复制代码

碰到的问题是,这个报表是多页的,通过预览打印没有问题,然而通过上述代码输出是打印机有多页走纸,却只打印出了第一页的内容。
请问是不是 pagereport 的这种静默输出的方式不能用于 RDL 报表?RDL 报表如何才能实现静默输出呢?
多谢!



8 个回复

倒序浏览
KearneyKang讲师达人认证 悬赏达人认证
超级版主   /  发表于:2020-7-8 09:09:27
沙发
您好,你的程序是Winform程序还是其他程序,你的报表的数据源链接使用的是数据库直连还是动态数据源绑定。你能提供 下 你的具体demo我这边进行验证看看
回复 使用道具 举报
netstone
注册会员   /  发表于:2020-7-8 09:49:20
板凳
本帖最后由 netstone 于 2020-7-8 09:54 编辑

winform 应用程序,数据源直连数据库的。报表预览打印正常,通过 reportviewer 加载后打印也正常。
回复 使用道具 举报
netstone
注册会员   /  发表于:2020-7-8 09:53:01
地板
  1. /// <summary>
  2.         /// 将报表直接打印输出
  3.         /// </summary>
  4.         /// <param name="ARSetting"></param>
  5.         /// <param name="sType"></param>
  6.         /// <param name="sFile"></param>
  7.         public static void PrintReport(linkReportPrint printSetting)
  8.         {
  9.             //public static void PrintReport(ActiveReportSetting ARSetting)

  10.             PageReport pageReport = ReportLoad(printSetting.ARSetting);
  11. pageReport.Run();

  12.             //pageReport.Document.Printer.DefaultPageSettings.Margins.Bottom = 0;
  13.             //pageReport.Document.Printer.DefaultPageSettings.Margins.Left = 0;
  14.             //pageReport.Document.Printer.DefaultPageSettings.Margins.Right = 0;
  15.             //pageReport.Document.Printer.DefaultPageSettings.Margins.Top = 0;
  16.             //pageReport.Document.Printer.PaperSize.RawKind = 0;
  17.             //pageReport.Document.Printer.PaperSize.Width = 14;
  18.             //pageReport.Document.Printer.PaperSize.Height = 20;

  19.             if ((printSetting.printerName != null) && (printSetting.printerName != ""))
  20.             {
  21.                 pageReport.Document.Printer.PrinterName = printSetting.printerName; // "Foxit Reader PDF Printer";
  22.             }

  23.             //pageReport.Document.Printer.PrinterSettings.Copies = 1;
  24.             //pageReport.Document.Printer.PrinterSettings.FromPage = 1;
  25.             //pageReport.Document.Printer.PrinterSettings.ToPage = 2;
  26.             //pageReport.Document.Printer.PrinterSettings.PrintRange = 0;

  27.             ////GrapeCity.ActiveReports.PrintExtension.Print(_document, true, true);
  28.             //GrapeCity.ActiveReports.PrintExtension.Print(pageReport.Document,
  29.             //    showPrintDialog: printSetting.showPrintDialog,
  30.             //    showPrintProgressDialog: printSetting.showPrintProgressDialog);

  31. pageReport.Document.Print(showPrintDialog: printSetting.showPrintDialog,
  32. showPrintProgressDialog: printSetting.showPrintProgressDialog,
  33. usePrintingThread: true);
  34. }
复制代码
  1.         /// <summary>
  2.         /// 根据指定的设置内容加载报表
  3.         /// </summary>
  4.         private static PageReport ReportLoad(ActiveReportSetting ARSetting)
  5.         {
  6.             string file_name = ARSetting.reportFile;
  7.             //string file_name = @"C:\TOTALLINK\REPORTS\TEST01.rdlx";

  8.             PageReport pr = new PageReport(new System.IO.FileInfo(file_name));

  9.             try
  10.             {
  11.                 //处理多数据源连接字符串
  12.                 for (int i = 0; i < ARSetting.connString.Length; i++)
  13.                 {
  14.                     if (ARSetting.connString[i] != "" && i < pr.Report.DataSources.Count)
  15.                     {
  16.                         pr.Report.DataSources[i].ConnectionProperties.ConnectString = ARSetting.connString[i];
  17.                     }
  18.                 }

  19.                 //处理参数列表
  20.                 for (int i = 0; i < ARSetting.para.Length; i++)
  21.                 {
  22.                     if (i < pr.Report.ReportParameters.Count)
  23.                     {
  24.                         pr.Report.ReportParameters[i].DefaultValue.Values.Add(ARSetting.para[i]);
  25.                     }
  26.                 }

  27.             }
  28.             catch (Exception)
  29.             {

  30.                 //throw;
  31.             }

  32.             return pr;
  33.         }
复制代码
上面是主要的代码,谢谢。
回复 使用道具 举报
KearneyKang讲师达人认证 悬赏达人认证
超级版主   /  发表于:2020-7-8 13:58:54
5#
您好,我同事已经给你电话沟通。这个问题最好可以给一个能重现问题的步骤,不然我们这边也不知道该如何解决
回复 使用道具 举报
netstone
注册会员   /  发表于:2020-7-8 14:55:14
6#
本帖最后由 netstone 于 2020-7-8 14:56 编辑


尝试直接通过 winform 客户端打印,showdialog = true 正常,false 的时候没有打印输出,请问什么原因?
=false 的时候,实际没有打印输出。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
KearneyKang讲师达人认证 悬赏达人认证
超级版主   /  发表于:2020-7-8 15:13:23
7#
你的意思就是调用Winform端的打印弹出打印窗口,打印正常,不弹出直接打印就没有打印输出是这样吗
回复 使用道具 举报
netstone
注册会员   /  发表于:2020-7-8 16:04:43
8#
是的。实际的环境是客户端的应用程序运行在一台服务器上,需要通过局域网的一台网络打印机输出。显示对话框的时候,打印正常,不显示对话框打印,就没有打印输出了。
打印机名是 \\bzj162\epson printer ... 这样指定的。
回复 使用道具 举报
KearneyKang讲师达人认证 悬赏达人认证
超级版主   /  发表于:2020-7-8 17:50:00
9#
你好,这个问题很诡异,然后跟我同事也沟通了,你们使用的方式比较复杂。目前我们这边也没有特别好的解决方案
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部