【问题标题】:Crystal Reports ActiveX Viewer水晶报表 ActiveX 查看器
【发布时间】:2013-02-06 17:43:23
【问题描述】:

在使用 Crystal Reports ActiveX 查看器(本例中使用 Delphi XE3)时,如何指定要查看的报表文件? CR 控件中没有可用于输入报表名称或位置的属性。

【问题讨论】:

    标签: delphi crystal-reports activex report


    【解决方案1】:

    Crystal Reports XI ActiveX 查看器不起作用。我猜你正试图用它来让 Crystal Reports 与 Delphi 一起工作。它没有。它甚至在其他任何地方都不起作用。最新安装的 Crystal Reports XI 甚至没有附带 ActiveX 版本,只有 .net 版本。

    仍然有安装程序(或在您的本地网络上)包含此 ActiveX 控件,但 CR XI 论坛讨论(现在由 SAP 管理的水晶报告)指出 ActiveX 控件在近十年前已被弃用,无法使用过去 5 年,并从 2 年前的最新安装程序中完全删除。

    【讨论】:

      【解决方案2】:

      ActiveXViewer 确实与 Delphi XE3 一起工作。这是一个示例:

      unit crystalreports;
      
      interface
      
      uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,       
      Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.OleCtrls,      
      ActiveX, ComObj, Data.DB, Data.Win.ADODB, CrystalActiveXReportViewerLib11_TLB;
      
      type 
      TReportForm = class(TForm)
       CrystalReportsViewer: TCrystalActiveXReportViewer; 
       PreviewButton: TButton; 
       procedure PreviewButtonClick(Sender: TObject); 
       private { Private declarations } 
       public { Public declarations } 
       end;
      
       var ReportForm : TReportForm;
      
       implementation
      
       {$R *.dfm}
      
       procedure TReportForm.PreviewButtonClick(Sender: TObject); 
          var CReport, CRApp : variant; 
          i :integer; 
      
      begin 
      CRApp := CreateOleObject('CrystalRuntime.Application'); 
      CReport := CRApp.OpenReport('C:\Crystal Reports Test\companydatasheet.rpt',0 ); 
      for i := 1 to CReport.Database.Tables.Count do 
      begin 
          CReport.Database.Tables[1].ConnectionProperties.Item['User ID'] := 'sa';  
          CReport.Database.Tables[1].ConnectionProperties.Item['Password'] := 'secret'; 
      end; 
      CReport.RecordSelectionFormula := '{member.member_no} = "101"';        
      CrystalReportsViewer.Align := alClient; 
      CrystalReportsViewer.ReportSource := CReport; 
      ReportForm.WindowState := wsMaximized; 
      PreviewButton.Visible := False; 
      CrystalReportsViewer.ViewReport; 
      CrystalReportsViewer.Show; PreviewButton.Visible := True; 
      end;
      
      end.
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-08-21
        • 2010-12-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-13
        • 1970-01-01
        相关资源
        最近更新 更多