The Company
Products
Solutions
Services and Support
Customers
Partners
News
Events
Home >> News >> WebFOCUS Newsletter >> July 2003 >> Conditionally Styling Reports in the Report Painter

Conditionally Styling Reports in the Report Painter

By Richard Kwiatkowski

FOCUS offers developers a powerful and flexible language to create and format tabular reports. While these reports offer all the information an organization requires, they may be lacking aesthetically.

To add visual cues to a report, and perhaps improve its readability, developers need to add FOCUS StyleSheet code, a separate language. Coding StyleSheets can be a tedious process. The Report Painter, however, offers an improved graphical environment to assist developers in adding conventional and conditional styling to a report.

Conditional styling does not need much of a definition. The name says it all: Report output displays a value or component differently from the rest of the report. For example, if sales are below a critical level for a region, the sales values appear in red.

Versions of Report Painter prior to Release 5.2 let a developer apply conditional styling to a report but offered a small subset of styling options – font, background color and grid. The current Report Painter offers many more conditional styling options and also supports conditional drill-downs.

To apply conditional styling to a column, a developer uses the Field Properties dialog box, which he or she may access by right-clicking a column and selecting Options. The Field Properties dialog box is a redesigned interface that organizes all of the styling options into a common dialog box. The dialog box’s Style tab contains the Conditional Styling controls.

The combination of the conditional styling controls with the styling options allows developers a fuller range of styling options for a true condition.

The basic steps for applying conditional styling are as follows:

1. Create the condition. Example:

SALES GT 15000
REGION EQ ‘Northwest’

2. Apply the condition to a report element. Example:

Column Data
Column Total

3. Apply styling options to the report element that the output displays when the condition is met. Example:

Font Color equals Red
Column Justification equals Center

Once a condition is defined for a report element, the Field Properties dialog box looks like what you see in Screen 1.

Screen 1

Notice the name of the condition appears below the Unconditional label. You use these labels to apply styling to the report element, in this case the data component of the DEALER_COST column. If the Unconditional label is selected, the Report Painter applies the styling to the report element, and sample output reflects this change. If a conditional label is selected, the Report Painter does not automatically apply the styling to the report element, but rather this change is reflected only in the actual report output.

Screen 1 shows that a developer has applied a condition to the Column Data component of a column and has assigned styling to the condition. The plus (+) sign to the left of COND0001 indicates that styling is associated with this condition. The Sample window shows how the actual data values will appear if the condition is met. In this example, when a DEALER_COST cost is greater than $15,000 the font for the value becomes white and the background becomes black.

An enhancement to the 5.2 version of the Report Painter is the ability to apply conditional drill-downs to a report. A Conditional drill-down behaves much the same way that conditional styling works. When a report element meets a condition, that element becomes hyperlinked and the drill-down becomes active.

A developer applies a conditional drill-down from the Drill Down tab on the Field Properties dialog box. The steps to apply a conditional drill-down are the same basic steps for applying conditional styling to a report element, except that instead of defining styling, you define a drill-down scenario.

Let’s take a look under the covers at the code that Report Painter generates for conditional styling.

When a developer creates a condition the Report Painter writes a Macro StyleSheet block that names the condition (COND0001) and specifies the condition that must be met (N2 GT 15000).

DEFMACRO=COND0001,
   MACTYPE=RULE,
   WHEN=N2 GT 15000,

At this point, the condition has not been applied to a report element for a reason. The Report Painter creates the Macro so that this condition can be applied to other report elements. If the Painter applied the condition directly to the report elements StyleSheet block, that condition would not be available for other report elements.

Once the condition is created and the Painter writes the Macro block, the developer can apply styling, including drill-downs, to a report element. The Report Painter writes the following StyleSheet code:

TYPE=DATA,
   COLUMN=N2,
   FONT='ARIAL',
   COLOR='WHITE',
   BACKCOLOR=RGB(64 0 64),
   STYLE=BOLD,
   MACRO=COND0001,

This StyleSheet code shows the report element (the data component of column N2), the styling options (Arial, white, bold font, with a background color) and the condition that must be met (COND0001).