【问题标题】:Import .rpt and .cs file of Crystal report to generate report导入水晶报表.rpt和.cs文件生成报表
【发布时间】:2022-01-16 15:11:38
【问题描述】:

我可以通过 OpenFileDialog 导入水晶报表的 .rpt 和 .cs 文件,但我不知道如何使用它来生成报表。是否可以只导入 .rpt 和 .cs 并使用导入的文件生成报告?

【问题讨论】:

    标签: c# crystal-reports


    【解决方案1】:

    添加对水晶报表 SDK (CrystalDecisions.CrystalReports.Engine) 的引用 https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

    然后打开报告

    using (ReportDocument rep = new ReportDocument())
    {
         //Open report
         rep.Load("SomeReport.rpt", OpenReportMethod.OpenReportByTempCopy);
    
         //rep.PrintOptions = ...
         rep.PrintToPrinter(1 /*NumCopies*/, true, 1, 9999);
    
         //or
         rep.ExportToDisk(ExportFormatType.PortableDocFormat, "SomeReport.pdf");
    }
    

    这假设报表知道从哪里获取数据。手动提供数据需要额外的步骤。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-01
      • 1970-01-01
      • 2016-03-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多