我被建议使用以下代码以PDF格式以编程方式呈现SSRS报告。 我试过了,但它没有用。
任何机构都可以建议可能需要的东西吗? 感谢
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()
答案 0 :(得分:1)
它不起作用,因为您从未向results
变量分配任何内容,因此FileStream永远不会写入任何内容。您需要将Render
方法的结果分配给results
:
results = ReportViewer1.LocalReport.Render(format, deviceInfo, mimeType, encoding, fileName, streamIDs, warnings)