Alternating row colors (or zebra striping as I’ve come to call it) is a very simple addition to any report or table that can make of world of difference in how readable the report is. When I was trying to accomplish this on a Crystal Report I’m creating I found that (as usual with Crystal Reports) it was very easy to do… once I figured out where to look.
To add the zebra striping first select ‘Report -> Section Expert’ from the file menu.
With the window that opens, first select the section from the left that contains the data you want to zebra stripe. Next, select the color tab and check “Background Color”. This will highlight all rows. To highlight on alternating rows you’ll have to add a bit of logic. Click the Formula Editor button (next to the color selector) to launch the Formula Workshop and add this line of code:
' ' 'Zebra Striping Logic ' ' If RecordNumber Mod 2 = 0 Then Color(238,238,238) Else crNoColor
The Color method take three parameters, the RGB spectrum respectively. The color I’ve entered (238,238,238) is a light gray.
Save the formula, and that’s it.