Here is a code snippet l got working which enables you to render using Visual Basic .Net an SSRS (Sql Server Report Services) Report to Adobe Acrobat PDF format or Microsoft Excel XLS file.
Public Sub RenderReportTOExcel(ByVal inReportFileName As String, ByVal inReportName As String) ’7/14/2008 SM
‘converts SSRS report to microsoft excel/acrobat pdf file
Dim objReportViewer As New FrmWithReportViewer
‘Dim strFormat As String = “PDF”
Dim strFormat As String = “Excel”
Dim strDeviceInfo As String = String.Empty
Dim myURLAccessParams As System.Collections.Specialized.NameValueCollection = Nothing
Dim reportStream As System.IO.Stream = Nothing
Dim strMimeType As String = String.Empty
Dim strFileNameExtension As String = String.Empty
Dim file_name As String = “d:\test001.xls”
objReportViewer.Text = inReportName
OFD.FileName = “exportfile.xls”
OFD.ShowDialog()
file_name = OFD.FileName
Dim raw As System.IO.FileStream = New System.IO.FileStream(file_name, IO.FileMode.Create)
Dim buffer(1024) As Byte
Dim read As Integer = -1
Dim intCount As Integer = 1
With objReportViewer.ReportViewer
.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote
.ServerReport.ReportServerUrl = New Uri(My.Settings.ReportServerURL)
.ServerReport.ReportPath = My.Settings.ReportPath + inReportFileName
reportStream = .ServerReport.Render(strFormat, strDeviceInfo, myURLAccessParams, strMimeType, strFileNameExtension)
lblMessage.Text = “Working…”
read = reportStream.Read(buffer, 0, buffer.Length)
While (read > 0)
raw.Write(buffer, 0, read)
read = reportStream.Read(buffer, 0, buffer.Length)
intCount += 1
End While
lblMessage.Text = “Completed.”
raw.Flush()
raw.Close()
raw.Dispose()
End With
raw = Nothing
reportStream = Nothing
End Sub