2015-11-05 80 views

回答

1

是的,這是可能的。這裏有一個代碼片段,用於將水晶報表對象(內存流)轉換爲Pdf,Word或Excel。

 using CrystalDecisions.Web; 
     using CrystalDecisions.Shared; 
     using CrystalDecisions.CrystalReports.Engine; 

     ReportDocument rpt = new ReportDocument(); 
     string path2 = path + reportName; 
     rpt.Load(path2); 
     CrystalDecisions.CrystalReports.Engine.Database crDatabase = rpt.Database; 
     ConnectionInfo crConnectionInfo = new ConnectionInfo(); 
     crConnectionInfo.ServerName = server; 
     crConnectionInfo.DatabaseName = db; 
     crConnectionInfo.UserID = crystalUser; 
     crConnectionInfo.Password = pwd; 
     crConnectionInfo.IntegratedSecurity = false; 

     <<<<<<report logic here>>>>>>>>>>> 

     CrystalDecisions.Shared.ExportFormatType typ = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat; 
     if (exportFormatType == "doc") 
      typ = CrystalDecisions.Shared.ExportFormatType.WordForWindows; 
     if (exportFormatType == "xls") 
      typ = CrystalDecisions.Shared.ExportFormatType.Excel; 

     MemoryStream ms = (MemoryStream)rpt.ExportToStream(typ); 
+0

雖然在將其導出爲pdf後,您忘記提及**