【问题标题】:Suggest correction in code to render report建议更正代码以呈现报告
【发布时间】:2014-03-29 11:11:26
【问题描述】:

有人建议我使用以下代码以编程方式以 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()

【问题讨论】:

  • 你不能直接写入 C:\Output.pdf 我猜,创建一个目录并授予写入权限。然后尝试类似 C:\some_writable_directory\Output.pdf

标签: vb.net reporting-services


【解决方案1】:

它不起作用,因为您从未将任何内容分配给 results 变量,因此 FileStream 将永远不会得到任何写入它的内容。需要将Render方法的结果赋值给results

results = ReportViewer1.LocalReport.Render(format, deviceInfo, mimeType, encoding, fileName, streamIDs, warnings)

【讨论】:

    猜你喜欢
    • 2021-06-21
    • 1970-01-01
    • 2018-12-18
    • 1970-01-01
    • 1970-01-01
    • 2015-12-30
    • 1970-01-01
    • 2023-03-16
    相关资源
    最近更新 更多