Coloring alternate data rows

Top  Previous  Next

Using conditional highlighting, it is easy to create reports having a "banded" look, where data lines are alternately colored. To save some effort, let's use the “Customer List” example that we designed previously.


Remove all the “Text” objects from the “MasterData” band. Place a “Text” object on the data band and stretch it to cover almost all of the band space:




This object will change its color dependent on the data line number. Select the object and set the following conditional expression in the Highlight tab of the object editor:


<Line> mod 2 = 1


Note: if you have selected C++Script as the script language (see more details in the "Script" chapter), you should write the condition using C++Script as:


<Line> % 2 == 1


Select a gray as the color for highlighting, not too saturated a color, but closer to white. Now the other objects can be added to the data-band on top of the first empty “Text” object:




On preview the report produces this output: