HomeDelphiHow to Install and use Crystal Reports in Delphi 7 ?

How to Install and use Crystal Reports in Delphi 7 ?

Are you looking at the tutorial on how to install and integrate crystal reports in Delphi 7? Here’ a blog post that explains with step by step instructions on how you can do it.

crystal reports in delphi 7

How to use crystal reports in Delphi 7?

To include the RDC runtime library into Delphi, start a new project in Delphi and follow these steps:

1. Select the Project menu and then the Import Type Library.

2. In the Import Type Library, Select Crystal Report x ActiveX Designer Runtime Library and rename the TReport and TDatabase class names to CRReport and TCRDatabase to avoid the naming conflicts

3. Click the Install button, click the Into New Package tab, provide a file name path for the new package, and select ok.

4. In the Confirm box, click Yes On Delphi’s ActiveX tab. There is now an Application object icon and CRReport object icon.

5. From Delphi’s ActiveX tab, place an Application object onto Form1. This adds OleServer and CRAXDRT_TLB to the Uses clause on Form1.

To work with RDC , we now require Report Object and the Application Object

1. Declare the report object and the Application Object
Eg :

report : IReport;

2. Open the report using the Application’s OpenReport function

report := Application1.OpenReport(‘c:\senthilreport.rpt’,crOpenReportByTempCopy);

The first parameter to the OpenReport function is the path of the report file .The second parameter’s description is as follows

1. The CrOpenReportByDefault locks the RPT file preventing it from being accessed by other users.

2. CrOpenReportByTempCopy opens a temporary copy of the RPT file.

Next we need to Add the Crystal Report Viewer Control to access the data in the Report .

To include the CRViewer into your project:

1. Select the Project menu and Import Type Library.

2. Select Crystal Reports Viewer Control and click the Install button. The CRViewer control is added to Delphi’s ActiveX tab.

3. Add the CRViewer control to Form1.

Set the ReportSource to the report created using the OpenReport function .

crViewer1.ReportSource := report; 
crViewer1.ViewReport;

You should see the Crystal Report viewer with the Data once you run the Project .

    1 Comment

  1. Dave
    October 25, 2012
    Reply

    Senthil,

    Using D7/CR10 to hit an MSSQL db via OLE DB I’m having a hard time changing the hard coded designated database the report template is hitting. I’m using statements like

    aReport.Database.Tables.Item[1].ConnectionProperties.Item[‘Initial Catalog’].Value:=newDB;

    but the report is still hitting the old db. Got any pointers?

Leave a Reply

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...