About conditional formatting
It is often useful to highlight certain parts of your report when particular conditions are met. For example, you can change the color of a value to red when it is greater than 5000. Report Builder provides two ways of adding conditional formatting to your report:
The Conditional Formatting and Format Exception dialog boxes lets you specify multiple conditions and formatting attributes (font, text color, border, and fill color) for a selected layout object. You don't write any code with this method.
The Format Trigger property allows you to code your own PL/SQL functions to perform conditional formatting. Because you write the code yourself, you have more flexibility and complete control when compared to using the Conditional Formatting and Format Exception dialog boxes alone.
For many conditions, you often can do what you need using the Conditional Formatting and Format Exception dialog boxes. For other conditions, you may want to use the dialog boxes to get started, and then modify the generated code by editing the Format Triggers.
To apply conditional formatting to a layout object:
1 Click the object, and then choose Format Conditional Formatting. Tip
2 In the Conditional Formatting dialog box, click New to display the Format Exception dialog box.
3 Specify the conditions and formatting attributes to be applied when the condition(s) evaluate to TRUE.
4 Click OK.
Using the Conditional Formatting and Format Exception dialog boxes, you can specify output formatting attributes (font and/or color) for a selected layout object based on conditions that exist. The conditions that you define are called format exceptions.
You can display the Conditional Formatting dialog box from the Live Previewer view or Layout Model view in any of the following ways:
- Double-click the object to display the Property Palette. Under the General Layout node, click the Conditional Formatting value field (labeled ¼).
- Display the pop-up menu (right-click in Windows) for the object.
- Click the object, then choose FormatConditional Formatting.
After you specify conditions and formatting for the current layout object in the Format Exception dialog box, the entire definition is exported to a PL/SQL format trigger automatically.
In the below screen shot, you can see that we are hiding an object based on certain condition.
(:sal Between '100' and '1000')
After creating a format exception in conditional formatting dialog box, a piece of code will be automatically generated in the format trigger of that object.
function F_SalFormatTrigger return boolean is
-- Automatically Generated from Report Builder.
if (:sal BETWEEN '100' and '1000')
If a format trigger already exists for the layout object, the definition in the Format Exception dialog box overwrites the existing trigger code when you confirm the Report Builder prompt.
You can edit the format trigger manually via the PL/SQL Editor; however, if you subsequently modify the definition using the Format Exception dialog box, Report Builder displays a prompt to overwrite the existing format trigger.