我必须开发一个asp.net网页,它将执行一些在SSRS中开发的报告。该报告包含其他一些子报告,它们被执行,结果被保存到excel和pdf中。我的问题是如何在Asp.net中运行这个报告和子报表?我知道如何执行单个报告,但它不是单个报告,它的报告\内部报告可以给我任何一个想法
发布于 2014-08-05 14:46:45
您需要将处理程序附加到报表的SubReportProcessing事件。在vb.net中:
AddHandler _report.SubreportProcessing, AddressOf RunSubReport
Sub RunSubReport(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
'Set ds to your dataset
e.DataSources.Add(New ReportDataSource("YourDataSourceName", ds))
End Sub有关向子报表添加参数的讨论,请参见此堆栈溢出问题:Microsoft Reporting: Setting subreport parameters in code
将它们添加到主要报告中是直接的:
'Passing in parameters to the report to display in the header
Dim paramCollection As New Collections.Generic.List(Of Microsoft.Reporting.WinForms.ReportParameter)
paramCollection.Add(New Microsoft.Reporting.WinForms.ReportParameter("startDate", startDate.ToShortDateString))
paramCollection.Add(New Microsoft.Reporting.WinForms.ReportParameter("endDate", endDate.ToShortDateString))
'Set report parameters
_report.SetParameters(paramCollection)https://stackoverflow.com/questions/25141191
复制相似问题