Creating Professional Reports using Crystal Report for Visual Studio.NET (Part 3)

Contributed by
Rating: 4 stars4 stars4 stars4 stars4 stars / 18
February 20, 2002
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

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 :

 

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.

 

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.

 

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.

 

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.

 

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

blog comments powered by Disqus
ASP.NET ARTICLES

- Implementing ASP.NET 4.0 Page.MetaDescriptio...
- ASP.Net Development Tips
- Intro to Sessions in ASP.Net
- Google Maps API Introduction in ASP.NET usin...
- Creating an ASP.NET 3.5 Gridview Image Galle...
- Encrypt QueryString in ASP.NET 3.5 using VB....
- ASP.NET 3.5 Drop Down List Controls
- Connect to Access Database with ASP.Net
- Secure Audio Streaming with ASP.Net and Flash
- Dynamic Sitemap and Navigation in ASP.Net
- Implement Gzip and Deflate Compression in AS...
- Run ASP.Net in Ubuntu with Apache
- ASP.Net Mono Website Contact Forms
- ASP.Net URL Rewriting Methods
- Murach`s ASP.NET 4 Web Programming with C# 2...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials