Suggest correction in code to render report

*爱你&永不变心* 提交于 2019-12-25 02:48:15

问题


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

回答1:


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)


来源:https://stackoverflow.com/questions/22730317/suggest-correction-in-code-to-render-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!