繁体   English   中英

在代码中从 .rdlc 导出 PDF 时,如何提高 LocalReport.Render 方法的性能?

[英]How can I improve the performance of the LocalReport.Render method when exporting PDF from .rdlc in code?

我想在代码级别呈现大型非图形报告(数千页),从 .rdlc 文件中省略只会阻塞浏览器的ReportViewer控件。 当我测试呈现大约 2000 页的报告时, Microsoft.Reporting.WebForms.LocalReport.Render方法需要大约半小时才能完成,这被认为是糟糕的用户体验。

是否有任何技巧或替代解决方案来提高渲染性能:在代码中,重新设计 .rdlc 文件,或其他地方,例如,只是增加硬件?

示例代码:

LocalReport localReport = new LocalReport();
localReport.ReportPath = Server.MapPath("~/report.rdlc");

SetDataSources(ref localReport);

string reportType = "PDF";
string mimeType;
string encoding;
string fileNameExtension;

string deviceInfo =
"<DeviceInfo>" +
"  <OutputFormat>PDF</OutputFormat>" +
"  <PageWidth>8.5in</PageWidth>" +
"  <PageHeight>11in</PageHeight>" +
"  <MarginTop>0in</MarginTop>" +
"  <MarginLeft>0in</MarginLeft>" +
"  <MarginRight>0in</MarginRight>" +
"  <MarginBottom>0in</MarginBottom>" +
"</DeviceInfo>";
}

Warning[] warnings;
string[] streams;
byte[] renderedBytes;

//Render the report
renderedBytes = localReport.Render(
            reportType,
            deviceInfo,
            out mimeType,
            out encoding,
            out fileNameExtension,
            out streams,
            out warnings);

非常感谢任何帮助,提前致谢!

<trust legacyCasModel="true" level="Full"/>放在web.config <system.web>标签内为我做到了。 更多细节在这里

返回数据表作为数据源的运行速度比对象列表快得多

生成大型 PDF 文件需要内存,但如果您需要,有一个技巧可以优化内存使用:

  1. 将报告生成为最多 5-10 页的单独 PDF 文档(使用特定的 PDF 库,如免费的iTextSharpPDF File Writer
  2. 然后将所有这些 PDF 文件合并为一个大的 PDF 文档。

当您控制报告生成的进度时,此技术也很有用。

删除 SSRS 报告中的所有表达式。 任何条件格式、着色和交替行,这应该会大大减少您的下载时间。

在我 5 个月的调查之后,没有办法以可接受的速度水平提高 RDLC 的性能。 RDLC 是为简单的报告创建的,例如收据和发票。 如果报表页数大于 100 且没有任何内部表达式,或大于 50 页具有动态内部表达式,则使用 html 是可接受的加载和呈现速度的最佳选择。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM