如何在没有CrystalReportViewer的情况下查看Crystal Report?

时间:2015-11-05 12:57:47

标签: asp.net crystal-reports crystal-reports-2010

我有一个Web应用程序,我只需要查看嵌入在网页中的报告。我不希望 CrystalReportViewer 侧面控件如打印,缩放,分页等。它的外观应该像扫描的文档图片。有什么帮助吗?

1 个答案:

答案 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);