回复 8楼lzlg的帖子
lzlg 你好,
提供一个解决方案,先保存两个 PageReport 文件为 rdf 文件,再通过 SectionReport读取两个 rdf 文件从而达到合并效果。
附件是测试 Demo:
需要替换数据源:
关键代码:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack)
- {
- return;
- }
- //PageReport1
- var rdfe1 = new GrapeCity.ActiveReports.Export.Rdf.RdfRenderingExtension();
- FileInfo savePath1 = new FileInfo(this.Server.MapPath("test1.rdf"));
- // convert the first report to RDF stream
- PageReport pr1 = new PageReport(new System.IO.FileInfo(this.Server.MapPath("PageReport1.rdlx")));
- PageDocument pd1 = new PageDocument(pr1);
- pd1.Render(rdfe1, new FileStreamProvider(savePath1.Directory, savePath1.Name));
- //PageReport2
- var rdfe2 = new GrapeCity.ActiveReports.Export.Rdf.RdfRenderingExtension();
- FileInfo savePath2 = new FileInfo(this.Server.MapPath("test2.rdf"));
- // convert the first report to RDF stream
- PageReport pr2 = new PageReport(new System.IO.FileInfo(this.Server.MapPath("PageReport2.rdlx")));
- PageDocument pd2 = new PageDocument(pr2);
- pd2.Render(rdfe2, new FileStreamProvider(savePath2.Directory, savePath2.Name));
- SectionReport sr = new SectionReport();
- SectionDocument sd1 = sr.Document;
- sd1.Load(this.Server.MapPath(savePath1.Name));
- SectionDocument sd2 = new SectionDocument();
- sd2.Load(this.Server.MapPath(savePath2.Name));
- sd1.Pages.AddRange(sd2.Pages);
- // upload the merged documents to the viewer
- this.WebViewer1.Report = sr;
- }
复制代码
谢谢 |