Using Existing Crystal Reports as Templates

Now that we've introduced the major benefits of Report Templates, let's actually apply a template to one of the reports created in an earlier hour. The report in Hour 5 is a good example.

The report as it looked in Hour 5 was pretty plain because the focus was on making sure that the data requirements were satisfied. There wasn't a lot of time to play with formatting, so now we are going to apply a template that has some nice grayscale formatting and an underlay applied.

  1. Open the report. Choose File, Open to get the Open dialog box, and browse until the report is found. (The report is probably named CHAP5.RPT). Choose it and click Open to continue.

  2. Look at the report prior to applying the template as shown in Figure 19.1. To get a good view of the application of the template, make sure that the Preview tab is selected. If the Preview tab is not selected or available, choose View, Preview.

    Figure 19.1. The report from Hour 5 as it appears in Preview.

    graphics/19fig01.jpg

  3. Apply the template. To apply some formatting quickly, choose Report, Template Expert. In the Template Expert dialog, feel free to choose each file so that you can see the associated thumbnail. For this case, let's choose Confidential Underlay, as shown in Figure 19.2, and then click OK.

    Figure 19.2. The Template Expert with the Confidential Underlay template chosen.

    graphics/19fig02.jpg

    graphics/lightbulb_icon.gif

    For more information on thumbnails, review the Preview Pictures coffee break at end of this hour.


  4. Save the report. The report will then open with the formatting from the applied template as shown in Figure 19.3. You can now save the report as CHAP19.rpt.

    Figure 19.3. The target report with the Confidential Underlay template applied.

    graphics/19fig03.jpg

graphics/bookpencil_icon.gif

You might have noticed that just about anything you do when designing a report can be undone if you don't like it. This is also true when applying templates. However, the mechanism of accomplishing this is slightly different from all other undo operations. It does not appear in the regular undo list on the Standard toolbar.

If you don't like a template that you've just applied or it doesn't accomplish what you had hoped for, you can undo this action by going back in to the Template Expert. At the bottom of the dialog box, you will find a button that says Undo the Current Template. After selecting it and clicking OK, the template is removed.


Understanding How Templates Work

A lot of report formatting tasks were accomplished in the two minutes it took to apply the template in the previous exercise, including

  • Adding the Powered by Crystal logo to the report (along with its ToolTip and hyperlink) from the Crystal Repository. The Crystal Repository is discussed in more detail in Hour 18, "Working with the Report Component Repository."

  • Adding an image that says Confidential as an underlay to each page of the report.

  • Modifying the fonts and positions of all the database fields.

  • Showing the Record Selection Formula on the report.

  • Adding dashed lines between all items in the Details Section.

  • Adding a rounded box around the Record Selection Formula.

  • Using a rounded box to show where groups start and end.

  • Moving the Field Headings for each data field into the Group Header and formatting them with double lines.

graphics/lightbulb_icon.gif

One of the more advantageous features of templates is that even if more fields are in the target report's Details section than the template has, it duplicates the data field formatting for those extra fields. It puts them into a separate Detail Section (usually titled Details B) so that they will all appear together but they won't overwrite each other. The fields can then be moved around without having to worry about applying the same formatting by hand.




Sams Teach Yourself Crystal Reports 9 in 24 Hours
Sams Teach Yourself Crystal Reports 9 in 24 Hours
ISBN: B003D7JUVW
EAN: N/A
Year: 2005
Pages: 230

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net