Tuesday, December 11, 2007

Formatting Reports

Positioning and Sizing Report Objects

After you have completed your functional report design tasks—connecting to the data source, adding report objects, and structuring the report—formatting the various objects on a report is the natural next step in the report design process. "Creating and Designing Basic Reports," objects can be added to a report via a variety of methods—dragging and dropping objects from the design explorers or selecting objects from toolbar and menu commands and placing them in the desired locations within the report sections—for quick and intuitive report creation. Upon successfully adding objects to your report, each of the respective objects can be positioned, sized, and formatted for display purposes, as demonstrated in the following exercise.

Let's begin the design of our report. The following steps will enable you to create your own Customer Contact Listing report:

  1. Open the Crystal Reports application and select to create a new report using the blank report layout from the Report Gallery dialog.

  2. From the Database Explorer dialog, expand the Create a New Connection list, and then expand the ODBC (RDO) node to present the ODBC dialog window that lists the available data sources. Select the Xtreme Sample Database from the list of data sources and click Finish to continue to the Database Expert dialog.

  3. From the Database Expert dialog, use the arrow (>) button to add the Customer table to the Selected Tables list on the right.

  4. From the View menu, select the Field Explorer command to open the Field Explorer dialog.

  5. From the Field Explorer, click and drag the Contact Last Name field onto the report's design view and place it to the far left of the Details section area.

  6. Follow the previous step to add the Contact First Name, City, and Email fields to the Details section of the report.

  7. From the Insert menu, select Text Object and drop the object in to the middle of the Report Header section and type Customer Contact List in the text field. Click anywhere outside the text object to remove the cursor focus from the text object.

Now that the report includes the field and text objects identified previously, it's time to focus on positioning and resizing these fields for display purposes.

  1. you might not be able to see the entire text entered in to the report title text object because it is not wide enough to display your text entry. To resolve this, click once on the report title text object located in the Report Header section so that it becomes highlighted. Using the dark blue handles that encompass the objects perimeters, float over the handle located on the right side of the text object with the mouse pointer; then click and hold the mouse button while dragging the handle farther to the right to widen the text object's display area.

    Notice that when you float over the perimeter handles of an object with your mouse cursor (or pointer), the cursor icon turns into an alternative shape, such as horizontal or vertical arrows, to illustrate that you can modify the object if you click on the handle.

  2. Now that you have widened the display area of your report title object using the concept of object handles, repeat this same step to modify the width of the field objects within the Details report section so that you can insert one additional object into the Details section of your report.

  3. Using the Field Explorer (as discussed earlier), insert the Phone database field from the Customer table into the Details section of your report. Based on the previous steps, practice positioning and sizing the objects in the Details section to accommodate for all the database fields.


    As you might have noticed, the field sizes are often large enough to show the entire field name in the Design view of the report. But from the Preview tab view of the report, you see that fields (such as the Email or Phone fields here) are cut off from the display area. This is not unusual, and it might require you to resize the field objects to ensure that they are appropriate for the report display area. It's best to use the report's Preview tab as a guide to formatting the layout of your reports.

  4. Now click the Preview tab to see a preview display of what the report will actually look like

If the Preview tab is not displayed in the application, you have not yet run the report against the database. To run the report, click the Refresh toolbar icon to execute the report to run—the Refresh toolbar icon is represented with a yellow lightening bolt.


Although it's important to understand the basics of report formatting, you will not necessarily have to go through the often arduous process of formatting reports every time. Report templates can be used to apply predefined and meaningful formatting characteristics in a very quick manner. "Designing Effective Report Templates," for more details on designing and using report templates.


Modifying Object Properties for Formatting Purposes

Now that the foundation of our report is complete, it is time to focus on how to improve the form of the report—the aesthetic characteristics.

We will concentrate on modifying various object properties to further improve the presentation value of the report. In doing so, we will be using the Format Editor to access a variety of specific properties, such as fonts, borders, colors, and alignment. The Format Editor is a commonly used dialog to quickly and easily modify all your report objects, and its contents are reflective of the specific object type being formatted (text, chart, database field, and so on).

  1. From our earlier exercise, return to the Design tab of your report and right-click on the report title text object (located in the Report Header section) and select the Format Text option from the list to bring up the Format Editor dialog.

    The Format Editor dialog allows you to adjust a variety of properties of the object organized within various tabs.

  2. Navigate to the Font tab of the Format Editor and select the Bold font style, a font size of 11, and a font color of Red.

  3. Select the Paragraph tab of the Format Editor and choose Centered from the Horizontal Alignment drop-down list.

  4. Now select the Border tab from within the Format Editor and then select Single from each of the four border Line Style drop-down lists (left, right, top, and bottom). Under Color, click the Background check box and select Yellow from the drop-down list as the background color. Based on all of your selected properties in the Format Editor, you should now see a representative example of the text object in the Sample area at the bottom of the dialog box. Click OK to save these settings and return to the Design tab on your report.

  5. To improve the effectiveness of your report, you can modify the database field column titles to provide more meaningful descriptions for the business users of your report. Working within the Design tab of your report, double-click on the Phone object in the Page Header section of the report. When the cursor's focus is on this object, you can delete, append, or update the text as you wish. Modify this text to read Telephone Number and then click anywhere outside the object to remove the cursor's focus from the object.

As an alternative to the Format Editor, you can also use the toolbar and menu commands to quickly apply common formatting techniques, such as font and alignment characteristics.

  1. From the View menu, select Toolbars to present the Toolbar dialog. Make sure that the Standard, Formatting, and Insert toolbar items are all selected and click OK.

  2. Click on the Preview tab to see a preview display of what the report will actually look like. Again, if the Preview tab is not displayed in the application, click the Refresh toolbar button to execute the report. From the Preview mode, hold down the Shift key on your keyboard and click each of the five column titles so that they are all highlighted with a dashed perimeter. With all five columns title fields highlighted, click the Bold toolbar button, represented with a large bold letter B on the formatting toolbar.


  3. With the five column title fields still highlighted, click the downward arrow located on the Font Color toolbar button, represented with an underlined letter A on the formatting toolbar. Select the bright blue color from the available list.


In order to make the Email field appear more meaningful to the business users of the report, let's format the Email database field values to resemble and behave like standard hyperlink text.

  1. To remove the cursor focus from the five column titles fields, click anywhere outside these field areas or press the Esc (escape) key on your keyboard.

  2. Click any of the actual Email field values to highlight the Email database field objects and right-click on the same object to present the pop-up menu.


    You can use the Hyperlink tab within the Format Editor to create hyperlinks to a Web site, email address, file, or another crystal report. A hyperlink is saved with your report and is available to other users as a way of linking additional information as it relates to your report. Hyperlink definitions can also be defined by formulas, thus making data-driven hyperlinks a very powerful feature of Crystal Reports.

  3. Select the Hyperlink tab after you have opened the Format Editor. From the available Hyperlink Types, select Current Email Field Value—this option will automatically create a hyperlink based on the values stored within this field in the data source, and these values must be formatted as proper email addresses in the data source.

  4. Now let's make the Email field appear as a standard hyperlink value, commonly known to have a blue underlined font style. Select the Font tab within the Format Editor dialog to apply the blue font color and select the Underline check box. Click OK to return to the report Preview, and then press Esc to remove the cursor focus from all report objects.

  5. Based on the completion of the previous step, your mouse pointer should now change into a hand icon as it floats over any of the Email field values on the report. This indicates that upon clicking on any of the Email values, you will initiate an email message to be sent to that address

No comments: