可以通过以下步骤完成:
rs.exe -i ExportReport.rss -s http://localhost/ReportServer -v ReportPath="/SampleReports/Report1", ExportFormat="EXCELOPENXML", FileName="C:\ExportedReports\Report1.xlsx"
其中,-i
参数指定了要执行的脚本文件,-s
参数指定了报表服务器的URL,-v
参数用于传递变量。在这个例子中,ReportPath
变量指定了要导出的报表路径,ExportFormat
变量指定了导出的格式为EXCEL,FileName
变量指定了导出的文件路径和名称。
Public Sub Main()
Dim format As String = "EXCELOPENXML"
Dim fileName As String = Globals!ReportName.Value + "." + format
Dim path As String = Globals!ReportFolder.Value + "\" + fileName
Dim definition As New [Byte]()
Dim warnings As Warning() = Nothing
Dim rs As New ReportExecutionService()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
rs.LoadReport(Globals!ReportPath.Value, Nothing)
definition = rs.Render(format, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
Dim stream As New FileStream(path, FileMode.Create)
stream.Write(definition, 0, definition.Length)
stream.Close()
Console.WriteLine("Report exported successfully.")
End Sub
这个脚本使用了ReportExecutionService类来加载报表并导出到指定的文件路径。你可以根据需要修改脚本中的变量和参数。
这样,你就可以使用命令行从SQL Server 2017 Reporting Services导出报表到EXCEL文件了。
腾讯云相关产品和产品介绍链接地址:
领取专属 10元无门槛券
手把手带您无忧上云