Reputation: 4997
I was suggested the following code to programmatically render SSRS report in PDF format. I tried it but it is not working.
Can any body suggest what might be required? Thanks
Dim format As String = "PDF"
Dim fileName As String = "C:\Output.pdf"
Dim reportPath As String = "/[Report Folder]/Invoice"
' Prepare Render arguments
Dim historyID As String = Nothing
Dim deviceInfo As String = Nothing
Dim extension As String = Nothing
Dim encoding As String
Dim mimeType As String = "application/pdf"
Dim warnings() As Microsoft.Reporting.WinForms.Warning = Nothing
Dim streamIDs() As String = Nothing
Dim results() As Byte
ReportViewer1.LocalReport.Render(format, deviceInfo, mimeType, encoding, fileName, streamIDs, warnings)
' Open a file stream and write out the report
Dim stream As FileStream = File.OpenWrite(fileName)
stream.Write(results, 0, results.Length)
stream.Close()
Upvotes: 0
Views: 734
Reputation: 20560
It doesn't work because you never assign anything to the results
variable so the FileStream will never get anything written to it. You need to assign the result of the Render
method to results
:
results = ReportViewer1.LocalReport.Render(format, deviceInfo, mimeType, encoding, fileName, streamIDs, warnings)
Upvotes: 1