我用下面的代碼從一個應用程序調用RDLC文件到另一個應用程序。下面的代碼駐留在一個應用程序中。 RDLC文件駐留在另一個應用程序中。如何在asp.net中爲RDLC ReportPath設置動態url?
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文件生成過程中失敗。如何解決上述問題?
我看到你編輯了你的文章。請進一步解釋你的意思是「上面的代碼在excel文件生成過程中失敗」。你有錯誤嗎?如果是這樣,什麼錯誤以及它在哪裏拋出?或者你得到一個空的Excel文件?還是什麼都沒有發生? – Oceans
您正在使用pdfcontent而不是excelcontent。你在哪裏試圖保存這個文件? – tezzo
@tezzo,我在應用程序中保存了生成的excel文件。 – RGS