Tuesday 24 April 2012

How to create Crystal report


Crystal Reports

Crystal Reports is a popular Windows-based report writer (report generation program) that allows a programmer to create reports from a variety of data sources with a minimum of written code. Developed by Seagate Software, Crystal Reports can access data from most widely-used databases and can integrate data from multiple databases within one report using Open Database Connectivity ( ODBC ).
Crystal Reports uses an ActiveX control called CrystalReport to establish a connection with another program. A programmer can set properties of the CrystalReport control during design time or at run time.
The programmer can use automation tools called Experts to be guided through common tasks, such as linking and embedding reports. Crystal Reports treats all text, graphics, and database fields as object s that a programmer can place, arrange, and format on forms. The program also generates a recordset object and code needed to perform programming tasks such as loop s or mathematical calculations.
Crystal Reports can create a report on the fly from user-defined variables and can convert it to HTML and publish it to the Web automatically.



Select New from the File menu to create a new report:
The Report Gallery screen will open. Select "Custom" to create a custom report:
Several Custom Report options will now display at the bottom of the Report Gallery:
Select the Data File button. The "Choose Database File" dialog box will come forward:
Select the "SQL Tables" button in the bottom right of the dialog. The "Log On Server" dialog will come forward. Select "Oracle Server" in the drop down and then "OK":
A dialog box will appear asking for your User ID, Password, and Server (database instance). Fill those in and select "OK":
Select the table(s) which you wish to include in your report, and "OK":
The Insert Fields dialog box will come forward:
You can also access the Insert Fields dialog box by using the menu item (if you selected "Close" before completion):
Before selecting fields, go to the Options command under the File menu:
Click on the check box for "Show Short Section Names in Design" and select "OK":
From the Input Fields dialog box, highlight a field. Select Browse and a screen will come up displaying the field name, type, length, and listing of field values:
From the Insert Fields dialog, select the desired field and drag it to the Details section of your report:
You can click on the SP_SUBNUM field and display the box surrounding it. Select a handle to drag the size of the box to make it smaller or larger as needed. Next we move the SP_LNAME field to the form.
Next, in the Insert Fields dialog, while holding down your Ctrl key, select several fields. Select the "Insert" button.
Move your mouse over to the field and click in the Detail section where you wish to place the fields:
Without doing anything fancy, select the Print Preview button and display the report:
If you have a lot of records in the table, you can click the solid square "stop" button on the right to stop running the report. Clicking the red [X] button will take you out of Preview mode.
By the way, be sure to save your report occasionally.
Another report option, found under the File/Options menu is to show the data representation, rather than the field name:
Under Field options, remove the check from the "Show Field Names" check box. Now fields will show with X's in the Design screen if they are character types, dollar amounts if currency, et cetera. Try it and see:
To give yourself more working room, you may wish to grab the divider bar underneath the Detail section and drag it down. This will open up more space.
In most cases, you'll want the last name, first name, and middle initial to be together. In order to do that, click the "Insert Text Object" button on the toolbar:
Move your mouse down to the form and you'll see a text object frame appear. Place it where you want it and Click to let it go:
Click on the new object until you see handles. Select a handle and drag it to the right to increase the width. Now double click on the object until you see an insert cursor.
From the insert fields dialog box, select the last name field, select insert. Move your cursor over to the new text object and click inside the box to place the last name field inside the new object:
Inside the new object box, after the "SP_LNAME" field, type a comma and space. Then select the "SP_FNAME" field and drag it over inside the object as well. (You can click and drag without selecting the "Insert" button.)
Type a space following the "SP_FNAME" field and then drag the "SP_INITIAL" field as well. You can now close the Insert Fields box.
You no longer need the other name fields, so select those on the report and delete them. Move the new object field into place on the form. Now give everything a nice meaningful header.
Now you are ready to Preview the report:

No comments:

Post a Comment