如何以编程方式从SQL Report Server 2008下载“RDL报告文件”

时间:2015-09-21 13:53:18

标签: vb.net reporting-services rdlc rdl

如何以编程方式(vb.net)从SQL Report Server 2008下载“RDL报告文件”。

我只需要下载所有报告并在一次点击活动中上传所有报告。这可能吗?

2 个答案:

答案 0 :(得分:0)

有几次,我使用了一个名为SSRSExtractor(开源)的程序。它可以在CodeProject.com http://www.codeproject.com/Articles/339744/SSRS-Downloading-RDL-Files

上找到

答案 1 :(得分:0)

我之前还有一些代码从ssrs服务器下载报告

public void SaveAdhocReportsToFile()
    {
        string inputPath = "Reports";
        string outPutDir = "D:\\Reports\\";
        ExportListItemToFiles("/" + inputPath, ".rdl", outPutDir, ItemType.Report);
    }

private void ExportListItemToFiles(string inputPath, string fileExtension, string outPutFolder, string itemType)
    {
        try
        {
            Console.WriteLine("Exporting " + itemType + " from SSRS - folder " + inputPath + " to " + outPutFolder);

            string outPutFile = string.Empty;
            List<CatalogItem> items = ReportService.ListChildren(inputPath, false).Where(x => x.TypeName == itemType).ToList();


            foreach (CatalogItem item in items)
            {
                byte[] rpt_def = null;
                XmlDocument doc = new XmlDocument();

                rpt_def = ReportService.GetItemDefinition(item.Path);
                MemoryStream stream = new MemoryStream(rpt_def);

                outPutFile = string.Format(@"{0}{1}" + fileExtension, outPutFolder, item.Name);

                if (File.Exists(outPutFile))
                    File.Delete(outPutFile);

                doc.Load(stream);
                doc.Save(outPutFile);
            }
        }
        catch (SoapException ex)
        {
            throw new Exception(ex.Message);
        }
    }

您可以参考ReportingService2010方法:https://msdn.microsoft.com/en-us/library/reportservice2010.reportingservice2010_methods%28v=sql.120%29.aspx