2015-09-21 57 views
0

如何從SQL報表服務器2008編程(vb.net)下載「RDL報告文件」。如何從SQL報表服務器2008下載「RDL報告文件」編程

我只需要下載所有的報告並上傳一次即可。這可能嗎?

+0

出於好奇,爲什麼呢?這是什麼目的?你是編程編輯文件,然後推它們備份到數據庫? –

+0

另外,你嘗試過什麼或者發現任何跡象表明這是可能在SQL Server 2008? –

+0

改寫文本 – Nikos

回答

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

相關問題