2010-07-28

使用 Crystal Reports ActiveX Viewer 開啟報表

使用 Crystal ActiveX Report Viewer Library 11.5 與 Crystal Reports ActiveX Designer Design and Runtime Library 11.5 開啟報表範例。
  • 透過 Type Class
procedure TfrmMain.BitBtn1Click(Sender: TObject);
var
  vRptFileName: String;
  vCRApp: TCRApplication;
  vCRRpt: TCRReport;
begin
  // Open Report Uses by Type Class
  vRptFileName :=
    ExtractFilePath(Forms.Application.ExeName) + 'testPaperSet.rpt';

  vCRApp := TCRApplication.Create(Self);
  vCRRpt := TCRReport.Create(Self);
  vCRRpt.ConnectTo(vCRApp.OpenReport(vRptFileName));

  CRViewer.ReportSource := vCRRpt.DefaultInterface;
  CRViewer.ViewReport;
end;
  • 透過 Interface
procedure TfrmMain.BitBtn2Click(Sender: TObject);
var
  vRptFileName: String;
  vCRApp: CRAXDDRT_TLB.IApplication;
begin
  // Open Report Uses by Interface
  vRptFileName :=
    ExtractFilePath(Forms.Application.ExeName) + 'testPaperSet.rpt';

  vCRApp := CoApplication.Create;

  CRViewer.ReportSource := vCRApp.OpenReport(vRptFileName, crOpenReportByDefault);
  CRViewer.ViewReport;
end;
CR

沒有留言: