C# 如何在asp.net中为RDLC ReportPath设置动态url?
我使用下面的代码从一个应用程序调用RDLC文件到另一个应用程序。下面的代码驻留在一个应用程序中。RDLC文件驻留在另一个应用程序中C# 如何在asp.net中为RDLC ReportPath设置动态url?,c#,asp.net,vb.net,rdlc,dynamic-rdlc-generation,C#,Asp.net,Vb.net,Rdlc,Dynamic Rdlc Generation,我使用下面的代码从一个应用程序调用RDLC文件到另一个应用程序。下面的代码驻留在一个应用程序中。RDLC文件驻留在另一个应用程序中 Dim RptVwr As New Microsoft.Reporting.WebForms.ReportViewer() Dim ds As DataSet = OBJ.GetInventoryProductDetails(plannerCode) Dim RptDtSrc As New Microsoft.Reporting.WebForms.Report
Dim RptVwr As New Microsoft.Reporting.WebForms.ReportViewer()
Dim ds As DataSet = OBJ.GetInventoryProductDetails(plannerCode)
Dim RptDtSrc As New Microsoft.Reporting.WebForms.ReportDataSource()
RptDtSrc.Name = "XXXXXX1"
RptDtSrc.Value = ds.Tables(0)
RptVwr.LocalReport.DataSources.Add(RptDtSrc)
Dim RptDtSrc1 As New Microsoft.Reporting.WebForms.ReportDataSource()
RptDtSrc1.Name = "XXXXXX2"
RptDtSrc1.Value = ds.Tables(1)
RptVwr.LocalReport.DataSources.Add(RptDtSrc1)
RptVwr.LocalReport.ReportPath = "http://localhost:58154/RDLC/GLA_InspectionList.rdlc"
RptVwr.LocalReport.EnableHyperlinks = True
Dim excelcontent As Byte() = RptVwr.LocalReport.Render("Excel", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
Dim FS As FileStream
FS = New FileStream(Save, FileMode.Create)
FS.Write(excelcontent, 0, excelcontent.Length)
FS.Close()
但上述代码在excel文件生成过程中失败。如何解决上述问题?我相信您忘记添加
数据源了,因此您的报表上没有显示任何内容
RptVwr.LocalReport.DataSources.Add(myDataSource)
更新:我认为问题可能是因为第二个项目在数据集中使用了不同的类。确保使用了正确的类和属性
也许您可以通过添加一个简单的数据源来测试它。例如,类似这样的内容:
RptVwr.LocalReport.Add(New ReportDataSource("MyClass", New List(Of [MyClass])() From { _
New [MyClass]() With { _
Key .MyProp = "MyProp" _
} _
}))
我看你已经编辑了你的文章。请进一步解释“上述代码在excel文件生成过程中失败”的含义。你有错误吗?如果是这样的话,会抛出什么错误以及在哪里抛出?或者你会得到一个空的excel文档吗?还是什么都没有发生?您使用的是pdfcontent而不是excelcontent。您想将此文件保存到哪里?@tezzo,我已将生成的excel文件保存在应用程序中。我明白了,请添加有关问题本身的更多信息,以便我可以在需要时更新我的答案。您有任何错误吗?我在执行过程中遇到了错误呈现报告问题。