Alternating shading for lines in Crystal Reports


Here is a new Crystal Reports tip from the Flexible Solutions GP Reports newsletter.  I have added an example with some screenshots to better illustrate.

Want to spruce up your Crystal report a little by adding alternate color shading to the lines? Here is how. (Click on the screenshots to see them clearer.)

As an example, let’s start with a report that lists of customers from the GP sample company:

customers01

I want to shade the alternating lines to make this a little easier to read.  Here are the steps:

  • Go to Report > Section Expert
  • Click on Details on the left and switch to the Color tab on the right
  • Click on the formula button:

customers02

  •  Copy/type the following formula in:

select RecordNumber mod 2
case 0: crWhite
case 1: color(222,222,222)

  • Click Save and Close
  • Click OK to close the Section Expert window

 Here are the results:

 customers04

You can make the color of the shading anything you want. Crystal has colors that you can call by name, here is the list: crBlack, crMaroon, crGreen, crOlive, crNavy, crPurple, crTeal, crGray, crSilver, crRed, crLime, crYellow, crBlue, crFuchsia, crAqua, crWhite. I have found that most of these are much too dark, so I just pick my own RGB colors.

If you want to shade Group lines instead of Detail lines, change the formula to the following: 

select GroupNumber mod 2
case 0: crWhite
case 1: color(222,222,222)

12 Responses to “Alternating shading for lines in Crystal Reports”

  1. Great! So simple yet so effective unlike other complicated tutorials for a simple question.

    Like this

  2. Thanks very helpful

    Like this

  3. thanks…great work

    Like this

  4. WOW!! Thanks… so easy. One question… if I want to pick a lighter shade as you were suggesting using your own RGB choices, how do I do that?

    Like this

    • Mana,

      You’d have to figure out the RGB numbers for the color you want. An easy way of doing this would be to go into any application that has a color option. For example, in Crystal 2008, select any field on the Design tab, click on the Font Color icon, choose More and play with the colors on the right side – once you find the color you like, note the Red, Green and Blue (RGB) numbers for it on the bottom right and fill those in instead of the 222,222,222 in my example. Hope that helps.

      -Victoria

      Like this

  5. Thanks for the tip Victoria :) Great one!

    Like this

  6. can u limit the width of the colored lines?

    Like this

  7. select RecordNumber mod 2

    whats “RecordNumber mod 2″? thanks

    Like this

    • Dru,

      The ‘mod’ function in Crystal divides one number by another and returns the remainder. So any odd number divided by 2 will have a remainder of 1 and any even number divided by 2 will have a remainder of 0.

      -Victoria

      Like this

Trackbacks/Pingbacks

  1. Selective highlighting in Crystal Reports - Victoria Yudin - January 15, 2010

    [...] the Background to Default Color, so that my alternate line shading is preserved. (Check out my Alternating shading for lines in Crystal Reports to see how to set up alternate [...]

    Like this

  2. Alternating shading for lines in Crystal Reports - Mohammad R. Daoud - September 12, 2009

    [...] If you would like to create report as the one shown below using crystal reports, checkout Victoria blog post HERE: [...]

    Like this

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,361 other followers

%d bloggers like this: