【问题标题】:Export all reports in RDL format from SSRS Server Automatically自动从 SSRS 服务器导出所有 RDL 格式的报告
【发布时间】:2016-03-17 15:44:21
【问题描述】:

SSRS 使您能够将报告导出为原始 RDL 格式:http://sql-articles.com/articles/general/download-export-rdl-files-from-report-server/

我想知道是否有办法将所有报告(通过我可以编写的命令行界面)或某些工具导出为原始 RDL 格式,然后可以压缩,等等。

感谢您的宝贵时间。

【问题讨论】:

    标签: reporting-services ssrs-2008 ssrs-2008-r2


    【解决方案1】:

    我没有对此进行测试,但它似乎可以满足您的需求。

    https://gallery.technet.microsoft.com/scriptcenter/SSRS-all-RDL-files-from-00488104

    【讨论】:

      【解决方案2】:

      我创建了一个 powershell 脚本来执行此操作。您必须连接到具有 SSRS 数据库的 SQL 服务器。它将所有文件压缩成一个 zip 文件。

      Add-Type -AssemblyName "System.IO.Compression.Filesystem"
      
      $dataSource = "SQLSERVER"
      $user = "sa"
      $pass = "sqlpassword"
      $database = "ReportServer"
      $connectionString = "Server=$dataSource;uid=$user; pwd=$pass;Database=$database;Integrated Security=False;"
      
      $tempfolder = "$env:TEMP\Reports"
      $zipfile = $PSScriptRoot + '\reports.zip'
      
      $connection = New-Object System.Data.SqlClient.SqlConnection
      $connection.ConnectionString = $connectionString
      
      $connection.Open()
      
      $allreports = $connection.CreateCommand()
      $allreports.CommandText = "SELECT ItemID, Path, CASE WHEN Type = 2 THEN '.rdl' ELSE 'rds' END AS Ext FROM Catalog WHERE Type IN(2,5)"
      
      $result = $allreports.ExecuteReader()
      
      $reportable = new-object "System.Data.DataTable"
      $reportable.Load($result)
      [int]$objects = $reportable.Rows.Count
      foreach ($report in $reportable) {
          $cmd = $connection.CreateCommand()
          $cmd.CommandText = "SELECT CAST(CAST(Content AS VARBINARY(MAX)) AS XML) FROM Catalog WHERE ItemID = '" + $report[0] + "'"
          $xmldata = [string]$cmd.ExecuteScalar()
          $filename = $tempfolder + $report["Path"].Replace('/', '\') + $report["Ext"]
          New-Item $filename -Force | Out-Null
          Set-Content -Path ($filename) -Value $xmldata -Force
          Write-Host "$($objects.ToString()).$($report["Path"])"
          $objects -= 1
      }
      
      Write-Host "Compressing to zip file..."
      if (Test-Path $zipfile) {
          Remove-Item $zipfile
      }
      [IO.Compression.Zipfile]::CreateFromDirectory($tempfolder, $zipfile) 
      
      Write-Host "Removing temporarly data"
      Remove-Item -LiteralPath $tempfolder -Force -Recurse
      
      Invoke-Item $zipfile
      

      【讨论】:

        猜你喜欢
        • 2022-01-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-01-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多