0
我有一個Web應用程序,我只需要查看嵌入到網頁中的報告。我不想要CrystalReportViewer側面控制,如打印,縮放,分頁等。它的外觀和感覺應該像掃描的文檔圖片。任何幫助?如何查看沒有CrystalReportViewer的Crystal Report?
我有一個Web應用程序,我只需要查看嵌入到網頁中的報告。我不想要CrystalReportViewer側面控制,如打印,縮放,分頁等。它的外觀和感覺應該像掃描的文檔圖片。任何幫助?如何查看沒有CrystalReportViewer的Crystal Report?
是的,這是可能的。這裏有一個代碼片段,用於將水晶報表對象(內存流)轉換爲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);
雖然在將其導出爲pdf後,您忘記提及**
如何生成PDF? – heringer
好主意。我真的很感激。 –