我有一个Web应用程序,我只需要查看嵌入在网页中的报告。我不希望 CrystalReportViewer 侧面控件如打印,缩放,分页等。它的外观应该像扫描的文档图片。有什么帮助吗?
答案 0 :(得分: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);