Report.ReportOut form = new Report.ReportOut(); form.BindingData = report => { #region BindingData ReportDataSource dataSource1 = new ReportDataSource("dsA", _reportA); ReportDataSource dataSource2 = new ReportDataSource("dsB", _reportB); ReportDataSource dataSource3 = new ReportDataSource("dsC", _reportC); ReportDataSource dataSource4 = new ReportDataSource("dsD", _reportD); ReportDataSource dataSource5 = new ReportDataSource("dsE", _reportE); ReportDataSource dataSource6 = new ReportDataSource("dsF", _reportF); ReportDataSource dataSource7 = new ReportDataSource("dsG", _reportG); ReportDataSource dataSource8 = new ReportDataSource("dsH", _reportH); report.LocalReport.ReportEmbeddedResource = "xx.Report.rdlc"; report.Drillthrough += (a, b) => { LocalReport re = (LocalReport)b.Report; if (re.ReportEmbeddedResource == "xx.ReportOut.rdlc") { #region ReportOut绑定报表数据 re.DataSources.Add(dataSource1); re.DataSources.Add(dataSource2); re.DataSources.Add(dataSource3); re.DataSources.Add(dataSource8); #endregion } else if (re.ReportEmbeddedResource == "xx.ReportIn.rdlc") { #region ReportIn绑定报表数据 re.DataSources.Add(dataSource1); re.DataSources.Add(dataSource2); re.DataSources.Add(dataSource3); re.DataSources.Add(dataSource4); re.DataSources.Add(dataSource5); re.SubreportProcessing += (x, y) => { y.DataSources.Add(dataSource6); y.DataSources.Add(dataSource7); }; #endregion } }; report.LocalReport.EnableExternalImages = true; report.LocalReport.SetParameters(paraA); report.LocalReport.SetParameters(paraB); #endregion }; form.Show();
报表设计,打开后第一个画面是Report.rdlc的页面,在这个页面里面有两个链接,这两个链接分别是打开ReportOut.rdlc和xx.ReportIn.rdlc的。报表实现多级分层,而且下级报表中嵌套两个子报表。
报表代码查询后台文件report.rar