我想在代码层面渲染非图形化的大型报告(数千页),避免使用会导致浏览器卡顿的ReportViewer
控件,而是直接从.rdlc文件中进行渲染。当我尝试渲染一个约有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);
非常感谢您的帮助,提前致谢!