Thursday 24 September 2009

How to alternate row colors using Conditional Formatting property?

It is useful to highlight some parts of a report to get the attention when some conditions are met: some sum is greater then a specific value, something is on minus etc.

Oracle Report Builder offers two ways of doing this in a report:

- With Conditional Formatting, attributes like font, text color, border, fill color can be modified when some condition is true without programming;

- Format Trigger property offers more flexibility because you write your own code to perform conditional formatting.

The next report is showing all the responsibilities from Oracle Applications that starts with ‘Oracle’. The report is based on this query:

select frt.responsibility_id, frt.responsibility_name,

fr.start_date responsability_start_date, fr.end_date responsability_end_date

from fnd_responsibility fr, fnd_responsibility_tl frt

where frt.responsibility_id = fr.responsibility_id

and frt.responsibility_name like 'Oracle%'

order by frt.responsibility_name;

The colors for the rows of the report must be white and light blue. For this, a Summary Column (in this case it has the name row_no) must be created for counting and keeping the row number (count the responsibility_id because it is never null):

We want odd rows to be light blue and the even rows to be white. A Formula Column named odd_no must be created to check for each row if row_no has an odd or an even value:


In Layout Model, for each field from the row in the repeating frame, create a new formatting rule with the Conditional Formatting property: if odd_no equals with 1 then Fill Color will be light blue.


The report will look like this:



1 comment: