Performing the Report Layout


The report layout steps consist of the following: adding report sections, adding report objects, adding data filters, organizing the data, and formatting the data.

Organizing Reports into Sections

First, you need to define and implement report sections. The report designer comes in several report sections, including the Report Header, Page Header, Details, Report Footer, and Page Footer. You can drag report objects from the Field Explorer into a report section. The report data associated with that report object varies depending upon where you place the report objects. If you insert a chart object into the Report Header section, for example, the chart will appear only once at the beginning of the report and will summarize all the data contained in the report. If you insert a chart object into the Group Header section, on the other hand, a separate chart will appear at the beginning of each group that summarizes the data contained within that group .

Adding Report Formatting Objects

Crystal Reports provides a number of report formatting objects that help the developer create truly customized forms and reports. The Field Explorer lists the field objects that add dynamic elements to the report. Drag a field object from the Field Explorer into a report section to mark the placement of extracted data. In the case of the OpenIssuesReport template, expand the Database Fields and Dat_Issue nodes. Drag a few of the listed column references into the Details section of the report, as shown in Figure 10-8.

click to expand
Figure 10-8: You use field objects to lay out data and text within the body of a report.

Text objects display static text and create titles, headings, and label summaries. If necessary, text objects can hold database fields as well as create custom forms and letters .

Properties define how the different reporting objects will appear in the final report. This includes special formatting such as font selection, border definition, paragraph spacing, and hyperlink definitions. You can open the object's Format Editor (shown in Figure 10-9) by selecting a placed report object and choosing Format from the pop-up menu.

click to expand
Figure 10-9: The object's Format Editor dialog box defines the format of placed report objects.

Filtering Necessary Application Data

In many cases, such as in OpenIssuesReport, not every record in a database is desired ”only those issues that are still marked open. In these cases, you need to apply a filter to select a certain subset of the table data. In Crystal Reports, you filter data using record selection formulas and parameters.

Filtering Data Using Record Selection Formulas

When you select a field to appear on a report, data values from every record in the table display by default. In many cases, you may not want to include all the values and instead display a subset of those values. Crystal Reports provides a formula language that specifies any type of record selection. In most cases, the powerful record selection flexibility that the formula language provides is not necessary. For simpler record selection, use the Select Expert.

Open the Select Expert by selecting Report ˜ Select Expert from the pop-up menu. Choose the table source that needs to be filtered. As Figure 10-10 shows, the source can be an existing report field that has been placed within the report or any field selection from an associated data source.


Figure 10-10: Select Expert filtering field selection

After you have selected the source field, click the OK button to enter the specific filter criteria. You can add any number of select filters to narrow down the desired record selection. Each select filter comprises a database field, a comparative operator, and a value, as shown in Figure 10-11. You can use any of the dozen comparative operators as well as a custom formula. For OpenIssuesReport, select the data field Dat_Issue.IssueID, choose the Is Equal To operator, and enter 0 for the value.

click to expand
Figure 10-11: Creating a select filter to retrieve specific records

When you select specific records, the report will be based only on the records that meet those conditions. If there is a need to select records based on part of the data within a specific field, then you need to create a record selection formula using the formula language. For example, you could evaluate the area code within a telephone number and then do a record selection based on that. To create a selection formula, open the report's pop-up menu and select Report ˜ Edit Selection Formula ˜ Records. The Record Selection Formula Editor displays, as shown in Figure 10-12.

click to expand
Figure 10-12: Creating presentation formulas with the Record Selection Formula Editor

Filtering Data Using Parameters

Parameter fields prompt the application user to enter additional information before generating the report. The information users enter determines what appears in the report. For example, in a report used by salespeople, a parameter might ask the user to choose a region. The report would return the results for the specific region instead of returning the results for all of the regions . Though it is useful to be aware of this feature, all reporting parameters should be captured by the application user interface and supplied to the report programmatically. Relying upon a Crystal Reports dialog box makes the report appear loosely integrated with the application. Figure 10-13 illustrates the awkward dialog box presented to the user when prompted to enter an issue priority.

click to expand
Figure 10-13: The Enter Parameter Values dialog box captures runtime input parameters.

Organizing Related Data Together

When you insert a database field into a report, the data within the field appears in the order in which it appears in the database. Grouping, sorting, and totaling functions turn disorganized data into useful information on a report.

Grouping Values Together

Most reports need to break data into sections so reports are easier to read and analyze. You can usually achieve this by grouping reported data. To create a report group, select the report, open the pop-up menu, and select Insert ˜ Group. In the Insert Group dialog box, select the field to be sorted and grouped by, as shown in Figure 10-14. Select the sort direction from the second dropdown list.


Figure 10-14: The Insert Group dialog box selects a field to be sorted and grouped.

Reports can also specify headers that label each group. By default, this group header displays the value of the field being grouped. Because this report is grouped by Dat_IssueID.PriorityID, the relative priority value displays at the change of each group. In the case of OpenIssuesReport, you can make the header even more readable by adding a text object that labels the group header.

To display a different value, such as the Issue author's name, you can customize the group name field by choosing an alternate data field or by creating a formula. When the Insert Group dialog box closes , two new sections appear in the report: Group Header #1 and Group Footer # 1. This is how Crystal Reports represents the existence of groups within a report and provides the developer with an area to enhance the group header and footer.

Sorting Column Data

When you add a database field to a report, the data values display in the report in the order in which they exist in the database. Sorting records helps organize data within a report so users can find and interpret reported information.

Data sorting is based on two criteria: the field to be sorted and the sort direction. The sort field is the data field that specifies the order in which data will be presented in a report. You can specify any data field as a sort field, including formula fields. The field's data type determines the method by which the data from that field is sorted.

The sort direction is the order in which data values appear in a report. Ascending order presents numeric values from smallest to largest and text values alphabetically. By default, Crystal Reports sorts data records in ascending order based on the values specified in the sort field. Descending order presents numeric values from largest to smallest and text values reverse alphabetically .

To sort data records displayed in a report, open the report's pop-up menu and select Report ˜ Sort Records. This opens the Record Sort Order dialog box, as shown in Figure 10-15. Select the data field to be sorted and click the > button to add it to the Sort Fields list. Next, specify the sort direction as Ascending or Descending. If sorting by more than one field, select the second data field and add it to the Sort Fields list. The order of the fields listed in the Sort Fields list represents the order in which report data will be sorted. Set the Ascending or Descending sort direction to the fields added to the Sort Fields list.

click to expand
Figure 10-15: The Record Sort Order dialog box

Totaling Numerical Values

Totaling can be as simple as providing the grand total at the bottom of a list of records or as complex as showing a running total based on conditions specified by a formula. In Crystal Reports, you can embed two types of totals within a report that help analyze data: subtotals and running totals.

A subtotal is a simple summary that sums all numeric values within a group. To create a subtotal , open the report's pop-up menu and select Insert ˜ Subtotal. The Insert Subtotal dialog box displays, as shown in Figure 10-16. Select the field to be subtotaled and the field that specifies the record sorting and grouping.


Figure 10-16: The Insert Subtotal dialog box specifies the field that must be summed.

Running totals offer more control over how the total is calculated and are ideal for any of the following: displaying totals record by record, displaying a total value independent of grouping, displaying a total value conditionally, and displaying a total value after a group selection formula has been applied.

To create a running total for a group, open the Field Explorer, select the Running Total Fields entry, and open the pop-up menu, as shown in Figure 10-17. Selecting New opens the Create Running Total Field dialog box, as shown in Figure 10-18.

click to expand
Figure 10-17: The Insert Grand Total dialog box
click to expand
Figure 10-18: The Create Running Total Field dialog box

Next, specify a reference name for the running total and specify the fields to be totaled. In this example, the running total will keep track of the number of records displayed within a group. Select Dat_Issue.IssueID from the available report fields and click the > button pointing to the Summary section. Specify the Type of Summary option as Count. The Evaluate section of this dialog box determines how the field is updated; for this example, choose For Each Record. Finally, keep the Reset value at its default value of Never and click OK. The rtotalNumIssues field becomes immediately available in the Field Explorer; you can now place it into the Group Footer section of the report.

Enhancing Report Presentation

Although simple reports are effective in communicating important data to users, Crystal Reports offers a number of enhancements that make a report stand out. Some of these enhancements include adding charts ; changing the presentation of dates, numbers , and other values; hiding unwanted sections; and performing additional formatting touches.

Inserting Graphical Charts

Crystal Reports supports sophisticated and colorful charts to be embedded within any report. Charting is an effective tool for presenting data and is valuable as a data analysis tool. Users can drill down into a chart and reference a chart's legend for detailed information. In most cases, charts represent summary and subtotal information at the group level. Charts can also represent summaries, subtotals, row data, formula data, running totals, and even cross-tab summaries. To embed a chart within a report, open the report's pop-up menu and select Insert ˜ Chart. The Chart Expert dialog box displays, as shown in Figure 10-19.

click to expand
Figure 10-19: The Chart Expert dialog box

The Chart Expert dialog box has three tabs. In the Type tab, select the type of chart to be generated. Available options include Bar, Line, Area, Pie, and a few variations. To accept the default options for the chart and axis formatting options, select the Automatically Set Chart Options box. Otherwise, two additional tabs appear to manually set the chart and axis formatting options. In the Data tab, specify how often the chart should appear within the report with the Place Chart selection. Also, specify whether the chart should be placed in the header or footer of the report. In addition, specify the database fields upon which the charts should be based. Finally, you can use the Text tab to override the default wording of chart-related labels, such as title, subtitle , footnote, group title, and data title.

Inserting Nested Subreports

A subreport is simply a report embedded within another report. You can aggregate several unrelated subreports into a composite report that presents multiple views of the same data. In most cases, reports with a large number of records in a section can appear in an on-demand subreport. The subreport appears as a hyperlink within the primary report. When the primary report is opened, the large volume of data to be retrieved for the subreport is not retrieved until the user selects the hyperlink.

To insert a subreport, open the pop-up menu for the report and select Insert ˜ Subreport. Drag the subreport border object into the report section. Select to use a report within the project, use another existing report, or create a new report for the subreport. Selecting the On-Demand Subreport checkbox enables the subreport to retrieve the data as needed. Otherwise, all subreport data will be retrieved with the parent report.

You use the Link tab, shown in Figure 10-20, to create the hyperlinks in the main report that bind to the subreport. Start by selecting the field in the main report from which you want to hyperlink. The Available Fields list box is filled with report fields that already have been added to the main report. Next, use the Field Link options to specify which main report field supplies a parameter to the subreport and the data upon which the subreport is based.

click to expand
Figure 10-20: The Insert Subreport dialog box

Inserting Cross-Tab Results

A cross-tab report is any report that displays a spreadsheet-like view of data organized into rows and columns. You can use cross-tab reports to compare data and identify trends. In Crystal Reports, a cross-tab object consists of three elements: rows, columns , and summary fields.

To insert a cross-tab object, select the report's pop-up menu and select Insert ˜ Cross-Tab. Drag the subreport border object into the report section. The Format Cross-Tab dialog box appears, as shown in Figure 10-21. Next, add the desired fields to the Rows, Columns, and Summarized Field areas. Select the Style tab to select a cross-tab design, or click the Customize Style tab to create your own Cross-Tab design. When finished, click OK ”a placeholder for the Cross-Tab table will appear.

click to expand
Figure 10-21: The Format Cross-Tab dialog box



Developing. NET Enterprise Applications
Developing .NET Enterprise Applications
ISBN: 1590590465
EAN: 2147483647
Year: 2005
Pages: 119

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