rs Utility is used to download SSRS report from command line. rs.exe is normally found under program folder.
It requires a script to download file. Lets make the name of the script download.rss. It is vb.net and it should be in .rss extension file.
It requires a script to download file. Lets make the name of the script download.rss. It is vb.net and it should be in .rss extension file.
Public Sub Main()
Dim format as string = "EXCELOPENXML"
Dim fileName as String = "E:\DownloadReport\RfsReport\Major Projects for CSOC Reporting - "+Date.Now.ToString("MM-dd-yy")+".xlsx"
Dim reportPath as String = "/RFS Reports/Major Projects - Singleview CSOC"
'Delete file if exists
If System.IO.File.Exists( fileName ) = True Then
System.IO.File.Delete( fileName )
End If
' 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
Dim warnings() AS Warning = Nothing
Dim streamIDs() as string = Nothing
Dim results() as Byte
rs.LoadReport(reportPath, historyID)
results = rs.Render(format, deviceInfo, extension, _
mimeType, encoding, warnings, streamIDs)
' Open a file stream and write out the report
Dim stream As FileStream = File.OpenWrite(fileName)
stream.Write(results, 0, results.Length)
stream.Close()
End Sub
Now run the following command
c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\rs.exe -i c:\download.rss -s http://[Report server name]/Reportserver -e Exec2005'Dim format as string = "EXCELOPENXML"
Dim fileName as String = "E:\DownloadReport\RfsReport\Major Projects for CSOC Reporting - "+Date.Now.ToString("MM-dd-yy")+".xlsx"
Dim reportPath as String = "/RFS Reports/Major Projects - Singleview CSOC"
'Delete file if exists
If System.IO.File.Exists( fileName ) = True Then
System.IO.File.Delete( fileName )
End If
' 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
Dim warnings() AS Warning = Nothing
Dim streamIDs() as string = Nothing
Dim results() as Byte
rs.LoadReport(reportPath, historyID)
results = rs.Render(format, deviceInfo, extension, _
mimeType, encoding, warnings, streamIDs)
' Open a file stream and write out the report
Dim stream As FileStream = File.OpenWrite(fileName)
stream.Write(results, 0, results.Length)
stream.Close()
End Sub
Now run the following command
No comments:
Post a Comment