AR16 RDL报表合并问题
使用 ReportCombiner 合并多个报表时,参照此例子可以实现但是如果此时报表使用的是动态数据源,需要使用_comBinerReport.Document.LocateDataSource 给数据时,如果存在A,B二个报表,怎么给数据,因为每个报表需要一个独立的DataTable
具体实现代码如下:
private void button1_Click(object sender, EventArgs e)
{
try {
var combiner = new GrapeCity.ActiveReports.ReportsCore.Tools.ReportCombiner();
var rpt1 = new GrapeCity.ActiveReports.PageReport();
rpt1.Load(new System.IO.FileInfo(@"..\..\Report1.rdlx"));
var rpt2 = new GrapeCity.ActiveReports.PageReport();
rpt2.Load(new System.IO.FileInfo(@"..\..\Report2.rdlx"));
combiner.SetMargin("0cm");
combiner.DefaultStep = "0cm";
combiner.AddReport(rpt1);
combiner.AddReport(rpt2, new LocationOptions() { PageBreakBefore = true, Gap = "5in" }); //adds second report after a page break and a 5 inch gap from the first report. By default this gap is 1 inch.
//combine reports
combiner.Mode = GrapeCity.ActiveReports.ReportsCore.Tools.CombineMode.ReportSections;
GrapeCity.ActiveReports.Document.PageDocument document = new GrapeCity.ActiveReports.Document.PageDocument(combiner.BuildReport());
document.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(Document_LocateDataSource);
System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@".\");
outputDirectory.Create();
GrapeCity.ActiveReports.Export.Pdf.Page.Settings pdfSetting = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
// Set the rendering extension and render the report.
GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfRenderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension("AAA"));
document.Render(pdfRenderingExtension, outputProvider, pdfSetting);
}
catch(Exception ex)
{
throw new Exception(ex.ToString());
}
}直接对合并后的报表做运行时数据源分配。然后可以在数据源里面,将所有用到的数据集名称都判断一下,然后赋值数据即可
另外 _combiner.AddReport 加入的 PageReport 设置数据是无效的,已经有试过 问题描述:
报表合并,运行时数据源测试问题
问题待测:您好,这个问题我们本地需要测试一下,如果复现,会回复您
页:
[1]