| Author |
Message |
gloworm
Groupie
Joined: 10 Oct 2011
Online Status: Offline
Posts: 47
|

Topic: Coloring sections of report Posted: 05 Feb 2013 at 9:52am |
|
I need to color certain sections of a report. For example each group would have a different color.
or
Is there a way to color a portion of the report according to size? Like 1"-3" would be green, 3"-7" would be yellow, 7-10 would be blue.
Would the coloring even export to excel?
Edited by gloworm - 05 Feb 2013 at 9:57am
|
IP Logged |
|
|
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|

Posted: 05 Feb 2013 at 11:25am |
Color according to size of the section or according to some size field in the database or formula in Crystal? Which version of Crystal are you using? There is no way to color according to the size of the section. However, if it's based on size in your data, then it shouldn't be a problem. And yes, this will export to Excel (but not to Excel - data only). In Crystal 2008 and above, go to the Section Expert and select the section that you want to color. - Select the Color tab. - Check the Background color checkbox. - Click on the formula button to the right of the color drop-down. - Enter something like this: Switch( {table.size} < 3, crGreen, ({table.size} >= 3 and {table.size} < 7), crYellow, {table.size} >= 7, crBlue, true, crNoColor) -Dell
|
|
|
IP Logged |
|
gloworm
Groupie
Joined: 10 Oct 2011
Online Status: Offline
Posts: 47
|

Posted: 05 Feb 2013 at 11:40am |
Originally posted by hilfy Switch( {table.size} < 3, crGreen, ({table.size} >= 3 and {table.size} < 7), crYellow, {table.size} >= 7, crBlue, true, crNoColor)
I dont understand this part, how it works.
|
IP Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|

Posted: 06 Feb 2013 at 2:27am |
In Crystal, a "Switch" statement is like a case statement. You have pairs of items - the first evaluates to True or False and the second is the result if the first statement is True. So, the Switch above sets the color to Green if the size field (whatever field or formula you get the "size" from) is less than 3, Yellow if it's greater than or equal to 3 and less than 7, and to Blue if it's greater than 7. You always put a final "true" statement at the end in order for it to work correctly. You could also do this as a long if..then..else statement, something like this: if {table.size} < 3 then crGreen else if {table.size} >= 3 and {table.size} < 7 the crYellow else if {table.size} >= 7 then crBlue else crNoColor The Switch statement required less typing, so that's what I tend to use when it's appropriate. -Dell
|
|
|
IP Logged |
|
gloworm
Groupie
Joined: 10 Oct 2011
Online Status: Offline
Posts: 47
|

Posted: 06 Feb 2013 at 4:46am |
|
I hate to be dense.........
Where do I get the size from? In my original post, I used the inches on the report as my example of where to set the colors.
Is it possible to say 0" to 3" on the report is green. It does not matter what is in the first 3", I want it green.
Then 3" to 7" be another color.
Then 7" to 10.5" are another color.
I did the section expert and it worked fine for the sub report. But when I color the sections on the main report, it goes all the way across the report.
I really would like to do it using the inches and have it encompass that whole area on the report, no matter what falls into it.
The thing I keep coming back to in my head is to do each of the sections as a sub report and plant them in a main report. That way I can color the section just like I did for the subreport I put in for the third section, per your suggestion.
When I color the section in the subreport, it colors just like I need it to be.
Can I link subreports to other subreports, inside a main report? Do I have to have tqables in the main report to link the subreports to?
|
IP Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|

Posted: 06 Feb 2013 at 4:53am |
If you look at my original post I say: There is no way to color according to the size of the section. However, if it's based on size in your data, then it shouldn't be a problem. So, if you're looking to do this based on the size of the section, it can't be done. The formula is assuming that you have some sort of size field in your data that you're working with. -Dell
Edited by hilfy - 06 Feb 2013 at 4:54am
|
|
|
IP Logged |
|
gloworm
Groupie
Joined: 10 Oct 2011
Online Status: Offline
Posts: 47
|

Posted: 06 Feb 2013 at 5:05am |
|
The thing I keep coming back to in my head is to do each of the sections
as a sub report and plant them in a main report. That way I can color
the section just like I did for the subreport I put in for the third
section, per your suggestion.
When I color the section in the subreport, it colors just like I need it to be.
Can
I link subreports to other subreports, inside a main report? Do I have
to have tables in the main report to link the subreports to, since the main is only the vessel holding the 3 subreports?
|
IP Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|

Posted: 06 Feb 2013 at 5:26am |
You MUST have at least one table or command in the main report. However, you don't actually have to USE the data. What I have done in the past for this type of thing is to create a command (SQL Select statement) that just returns the current date but then I don't actually use it anywhere. In terms of linking, you have two options: - If your subreports will only appear once and you filter your data based on a parameter, I would do the following: 1. Create a parameter in the main report. 2. In the Linking Expert for each subreport, select the parameter from the main report and use that to link to the data in the subreport. - If your subreports will appear multiple times because you need to group the data based on some field, then you would do this: 1. Add the main table for your report to the main report. 2. Create a group based on data in that table. 3. Put your subreports inside the group - usually in either group header or group footer sections. 4. Link to the subreports based on data from the table. -Dell
|
|
|
IP Logged |
|
Schugs
Newbie
Joined: 08 Aug 2012
Online Status: Offline
Posts: 36
|

Posted: 06 Feb 2013 at 11:29am |
|
The other option that might fit your needs is having a "Details a" section that is the total length of the paper, and put colored boxes there, then in the section expert choose "underlay following sections" and in "Details b" put your data.
I'm not sure if thats what you are looking for, but its a way you can put a set "3 inches of green, then 4 inches of blue" behind any text on your report.
|
IP Logged |
|
|
|