Creating a formatting rule
BIRT Report Designer provides an easy way to apply conditional formatting to report elements. Use the Highlights page of Property Editor to create a formatting rule that defines when and how to change the appearance of an element. When creating a formatting rule, specify the following information:
*The condition to meet in order to apply a format, for example, row["OrderTotal"] Greater than 50000.
*The format to apply, for example, font color = blue. You can also specify a style to apply.
Figure 8‑17 shows an example of a formatting rule.
Figure 8‑17 New Highlight showing a formatting rule
How to create a formatting rule
1 In the layout editor, select the report element to format conditionally.
2 Choose the Highlights tab in Property Editor. The Highlights page appears, as shown in Figure 8‑18. It is empty if you have not yet specified any formatting rules for the selected element.
Figure 6-11 Highlights pageFigure 6-11 Highlights page
Figure 8‑18 Highlights page
3 Choose Add to add a new formatting rule.
4 In New Highlight, create the rule for applying a particular format to the report element by completing the following steps:
1 Think of the rule in plain English first. For example:
If the order total is greater than $50,000.00, then set
the font color to blue and the font style to bold.
There are two parts to the rule: If (condition) and Then (format). The New Highlight dialog helps you specify the condition and format parts of the rule by breaking them down to more specific parts.
2 Specify the condition part of the rule by completing the following steps:
1 In the first field, specify the first part of the conditional expression. Using the example rule, this part is order total:
*If the order total values come directly from the selected element, from the drop-down list, choose Value of this data item.
*If the order total values come from another data element, choose that element’s column binding name from the drop-down list.
2 In the second field, specify the second part of the conditional expression by selecting an option from the list. Using our example rule, this part is Greater than.
3 In the third field, specify the third part of the conditional expression. Using our example rule, this part is a value of 50000, as shown in Figure 8‑19.
Figure 6-12 Elements of the conditional expressionFigure 6-12 Elements of the conditional expression
Figure 8‑19 Elements of the conditional expression
You have now completed the condition part of the rule, which specifies the following:
If row["OrderTotal"] is greater than 50000
3 Specify the format part of the rule, which is “then set the font color to blue and the font style to bold,” by completing the following steps:
*Choose Color, then select a color from the color picker.
Bold button
*Choose B to select the Bold format, as shown in Figure 8‑20.
Figure 6-13 Elements of the formatting expression in New HighlightFigure 6-13 Elements of the formatting expression in New Highlight
Figure 8‑20 Elements of the formatting expression in New Highlight
*Alternatively, if you created a style named order_data_highlight, for example, which specifies the formats, you can select the style from the list of styles next to Apply Style.
4 Choose OK to save the highlight rule.
The rule that you created appears in Highlight List, as shown in Figure 8‑21. The rule takes effect the next time you run the report.
Figure 6-14 Highlight ListFigure 6-14 Highlight List
Figure 8‑21 Highlight List
5 Preview the report to test your formatting rule.