请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册

QQ登录

只需一步,快速开始

linyimin

初级会员

32

主题

102

帖子

324

积分

初级会员

积分
324
linyimin
初级会员   /  发表于:2025-4-8 14:37  /   查看:87  /  回复:3
1金币
                            ActiveReports net版本,如果实现不同报表模版,批量打印功能。

3 个回复

倒序浏览
Felix.LiWyn认证
超级版主   /  发表于:2025-4-8 15:58:48
沙发
您可以直接代码调用,然后循环调用即可:

  1. GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport();
  2. GrapeCity.ActiveReports.PrinterSettings printerSettings = new GrapeCity.ActiveReports.PrinterSettings();
  3. printerSettings.ShowPrintDialog = false;
  4. printerSettings.Printer.PrinterName = @"Microsoft Print to PDF";
  5. pageReport.Load(new System.IO.FileInfo(@"..\..\Reports\In-OutSourcingQuery.rdlx"));
  6. GrapeCity.ActiveReports.Document.PageDocument pageDocument = new GrapeCity.ActiveReports.Document.PageDocument(pageReport);
  7. pageDocument.Print(printerSettings);
复制代码
类似于您重复调用以上内容,然后指定打印机名称即可。ShowPrintDialog 就是控制不显示打印窗口,即可直接批量打印
回复 使用道具 举报
linyimin
初级会员   /  发表于:2025-4-9 16:34:58
板凳

我这边12版本,代码提示没有PrinterSettings该对象类型定义,麻烦提供完整的代码吧,还有如何填充打印数据呢?

本帖子中包含更多资源

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

x
回复 使用道具 举报
Felix.LiWyn认证
超级版主   /  发表于:2025-4-9 18:09:57
地板
  1. // Provide the page report you want to render.
  2. System.IO.FileInfo rptPath = new System.IO.FileInfo(@"..\..\PageReport1.rdlx");
  3. GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(rptPath);

  4. // Create an output directory.
  5. System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyPDF");
  6. outputDirectory.Create();

  7. // Provide settings for your rendering output.
  8. GrapeCity.ActiveReports.Export.Pdf.Page.Settings pdfSetting = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings();

  9. // Reduce the report size and report generation time.
  10. pdfSetting.OptimizeStatic = true;

  11. // Set the rendering extension and render the report.
  12. GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfRenderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
  13. GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
  14.             
  15. // Overwrite output file if it already exists
  16. outputProvider.OverwriteOutputFile = true;

  17. pageReport.Document.Render(pdfRenderingExtension, outputProvider, pdfSetting);
复制代码
老版本您参考这个。

然后填充打印数据没太懂,报表基本本身都是直接连接数据库的,应该直接可以获取数据,
您说的填充数据,我理解唯一一种就是运行时数据源,需要运行时代码赋值,如果是这种,您参考:
https://help.grapecity.com.cn/5968575.html
两种运行时数据源您按照您自己使用的添加给pageReport对象即可
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部