0

I have used below code to call RDLC file from one application to another application. Below code resides in one application. RDLC file resides in another application.

 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()

But above code fails during excel file generation. How to fix the above issue?

RGS
  • 5,131
  • 6
  • 37
  • 65
  • I see you've edited your post. Please explain further what you mean with "above code fails during excel file generation". Do you get an error? If so, what error and where does it get thrown? Or do you get an empty excel document? Or does nothing happen at all? – Oceans Sep 29 '15 at 09:23
  • you are using pdfcontent instead of excelcontent. where are you trying to save this file? – tezzo Sep 29 '15 at 09:25
  • @tezzo, I have saved the generated excel file inside application. – RGS Sep 29 '15 at 09:30

1 Answers1

0

I believe you're forgetting to add a DataSource so you have nothing to display on your report.

RptVwr.LocalReport.DataSources.Add(myDataSource)

Update: I believe that the issue might be caused by the fact that the second project uses different classes in the DataSet. Make sure that you're using the correct classes and properties.

Perhaps you can test it by adding a simple datasource to test. For example something along the lines like this:

RptVwr.LocalReport.Add(New ReportDataSource("MyClass", New List(Of [MyClass])() From { _
    New [MyClass]() With { _
        Key .MyProp = "MyProp" _
    } _
}))
Oceans
  • 3,445
  • 2
  • 17
  • 38
  • I see, please add more information about the problem itself so i can update my answer where needed. Do you get any error? – Oceans Sep 29 '15 at 09:25
  • I got error rendering report issue during execution. – RGS Sep 29 '15 at 09:43