2010年5月19日

报表转pdf,直接在网页上显示

Rendering the output of a ReportViewer control (SQL Reporting Services) directly to PDF is fairly easy. It involves simply rendering the Report Viewer output to a byte array, and then pushing it to a MemoryStream object and writing to the Output Stream. Code below:

Dim warnings As Warning() = Nothing

Dim streamids As String() = Nothing

Dim mimeType As String = Nothing

Dim encoding As String = Nothing

Dim extension As String = Nothing

Dim bytes As Byte()

bytes = ReportViewer1.ServerReport.Render("PDF", Nothing, mimeType, encoding, extension, streamids, warnings)

Dim
ms As New System.IO.MemoryStream(bytes)

Response.ContentType = "Application/pdf" 

Response.BinaryWrite(ms.ToArray())

Response.End()



没有评论:

发表评论