Crystal Report 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 aoid the naming conflicts

3. Click the Install button, then 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 .

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

One Response

  1. Dave October 25, 2012 Reply

Leave a Reply


x

Interesting BlogPosts to read

Delphi 1 to XE7: 20 Years of Continuous Innovation by David I
Here's a video on Delphi 1 to XE7: 20 Years of Continuous Innovation by David I which talks about th...
FileHelpers - Free .NET library to Import and export data
FileHelper is a free .NET library which lets the developers to import or export data from fixed leng...
How to Switch to ART in Moto G (Android) device ?
ART stands for Android Runtime which is a method developed by the android development team for handl...