Creating Professional Reports using Crystal Report for Visual Studio.NET (Part 3)
 
Published: 12 Feb 2004
Unedited - Community Contributed
Abstract
In this last part of the series, we will take a look at how conditional formatting can help us hide/display a section of the Crystal Reports report. Conditional formatting refers to those formatting that are triggered only when certain condition is satisfied. Note that these formatting will override any fixed formatting done earlier using the Format Editor.
by Eric Landes
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 26868/ 49

Introduction

Editor's Note: The first edition of this article was written by Ajay Varghese.

In this last part of the series, we will take a look at how conditional formatting can help us hide/display a section of the report.  Conditional formatting refers to those formatting that are triggered only when certain condition is satisfied.  Note that these formatting will override any fixed formatting done earlier using the Format Editor.

For our current requirement, the Group 1 Footer (Store Details) should be visible only when the Store details are being displayed, and should be hidden while displaying the Book Details.  In other words, we need to get rid of the dangling parent row.  To achieve this, we will take an approach of assigning a value to a variable in the higher level section (Report Header) and displaying the details depending on the value of the variable in the lower level sections. The following steps can be used to implement this :

Create and Modify Formula

1. Create a new formula field as explained in the previous part, and type in the below shown code into the Formula Editor window (Note that we are using Crystal Syntax here to assign a value 1 to the variable RH).

2. Drag and drop the formula on to the Report Header section

3. Hide the formula field so that it doesn’t appear on the report. This can be achieved by right-clicking on the formula field (on the report), select Format, select the Common tab, and check the option Suppress.

4. Right click on the Group 1 Footer panel, select Format Section. This should bring up the Section Expert window.

5. Click on the x-2 symbol, next to the Suppress (No Drill Down) checkbox and type in the code shown below into the formula editor window. Here, we check for the value of the variable to decide if the details should be displayed or not.

Note that you will have to repeat the above steps (with a different variable) to make sure that the Footer 2 (Book Details) does not get displayed while viewing the Order details.

Improving Report Presentation

Now view the report in a browser and you will notice that we have got the same functionality as that of the report that we saw at the beginning of this walkthrough.

To improve the presentation of the report, you can get rid of the default headings that were generated by the wizard and instead use a Text Object to represent the headings and format it with various effects.

Crystal Report provides a number of options to choose from while formatting a Chart. I leave it to you to select a combination that suits your taste.  To get to the Chart Format Editor, right click on the Chart, select Format Chart, and then select General.

Click here to see how the report should look like in a browser

As the Stores table in the PUBS database doesn’t contain multiple orders for the same Store and Title combination, you will find only a single row every time on the Order details report.  If you try inserting some records directly to the table, you would notice that we still have a problem of the Order heading being repeated for each Order detail row.  This can be easily fixed by right clicking on the Order heading, selecting Format, and checking the Suppress if duplicated option.

Additional Formatting

You could also include some additional formatting like marking the quantity red when it is below a certain value and marking it green when it is above a certain value. This can be achieved by right clicking of the Quantity field on the report, selecting Format, selecting the Font tab, clicking on the x-2 symbol next to Color, and specifying a condition like :

If {Sales.Qty} > 50 Then
   crGreen
Else If {Sales.Qty} < 50 Then
   crRed
Else

   crBlack

Different reports would have different requirements. Reports without any Groups or with just one Group could be much simpler. As the number of Groups increase, the report creation could get more complicated. The important thing to remember here is that using a combination of the Header and Footer, Formulas and Conditional Formatting will give you total control over designing the report to your specific requirement.

Conclusion

That brings us to the end of this walkthrough and we hope you enjoyed reading it.  You are most welcome to send us your suggestion/feedback.  We would try to respond to any clarifications sent to us. Due to time constraint if we are not able to get in touch with you personally then we suggest that you sign up with some of the mailing lists/discussion groups where the experts hang out. Personally, we find these two groups most helpful. They have categories that covers any topic related to .NET .

 
        

Submitted by

Ajay Varghese & Shankar N.S

Sr. Software Engineers

Jarvis Infotech

< < Part 2




User Comments

Title: Crystal Report   
Name: Sharad Kumar Agarwal
Date: 2006-02-17 2:27:25 AM
Comment:
Hi ,
This is sharad here , i have doubt about the functionality of the linking in crystal report at run time.Currently i am using Crystal Report XI.
Suppose i am using two tables A and B and there is no linking between these two but have one column same in both the table .I put one -2 column from both the table in the report and i want to know the functionality how this two columns linked with each other at run time.

Waiting for reply.
Thanks
Sharad Kumar Agarwal
Title: Improving Report Presentation and Additional Formatting   
Name: Alexander
Date: 2005-09-22 7:38:32 PM
Comment:
Excelentes tips, me ayudaron mucho
Title: Crystal report dynamic formating in VS2005   
Name: Pooja
Date: 2005-08-31 5:34:47 AM
Comment:
Hello,

I have visited your site and it helps lot.But i need dynamic formating in crystal report.I mean to say instead of giving a static font size or color to the field in the crystal report, the field changes as per the user requirement.for example there are two tables in one table there is name and address field and in other table there is font size and color.The report display the name and address in the format given in the second table.
Please tell me steps need to perform the above request

Regards
Pooja
Title: addn formating   
Name: kiran (IS)
Date: 2005-04-05 7:28:20 PM
Comment:
this is very good tip which helped me a lot
Title: crystal report   
Name: Rinkesh patel (gop_vvn2585@yahoo,com)
Date: 2005-03-03 12:03:33 AM
Comment:
hi,developer
i developed one project on saradar patel university
i need to developed report with the parameterised in which i give input as year=2003,month=april,course_id=BCA and yeraor sem=1or2or 3 then collegename is PCI,after giving this input
the report will be generate i try well but this type of report not generate,it is available in vb 6.0 in datareport
i developed in asp.net.
so,u give me code for that.

i thank full u,
your sincearly
rinkesh patel
Title: CYRSTAL REPORT   
Name: KUNALSINGH(kunal.singh@india.birlasoft.com)
Date: 2004-09-30 9:29:33 AM
Comment:
HI,
i VIST THE ABOVE SITE AND FOUND SO MANY GOOD THINGS THAT WILL HELP ME WHEN I WILL GO FOR COMPLEX REPORT DESIGN. bUT BEFORE THAT I NEED ONE HELP FROM U THAT I KW ONLY BASIC REPORT GENERATION . LIKE AFTER CONNECTION FETCH THE DATA FROM ONE SINGLE TABLE.THAT IS ASP.NET. i WANT TO LEARN MORE STEP BY STEP . IF U HV ANY URL THAT HELP ME SETP STEP METHOD THEN IT WILL BE A G8 HELP FOR ME. i FOUND SO MANY GOOD THING IN UR SITE BUT I NEED FEW CODING STUFF THAT IT WILL HELP IN DEVELOPEMENT POINT OF VIEW.
REGARDS,
KUNAL SINGH

Product Spotlight
Product Spotlight 



Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-25 11:05:19 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search