Browse DevX
Sign up for e-mail newsletters from DevX


The Baker's Dozen: 13 Productivity Tips for Crystal Reports and .NET : Page 2

These 13 tips show you how to build tools to address common reporting requirements for your business using Crystal Reports with .NET.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Tip 1: The First Report
Building a quality report means more than just understanding the capabilities of the reporting tool: it also means defining the layout, queries, and data requirements, identifying any special calculations and business rules, adhering to output formatting guidelines, etc. I've built over two hundred reports over the last fifteen years (some easier than others), and in practically every case, the following needed to be determined and identified:
Figure 3: When you design a dataset for your first report, the datatables might look like this.
  • The report content (including calculations, subtotals, etc.)
  • Whether the layout conforms to any organization standards (font, margins, annotations, etc.)
  • Run-time options for the report
  • Report visibility (which user types were authorized to run the report, and if so which measures were they allowed to see)
  • Data schema used for the report, and how the data will be retrieved
  • How the report should be presented (preview first, or directly to the printer, etc.)
I certainly can't cover all of these in one article, but I can cover the specific steps with respect to Crystal Reports. Assume you've been given the requirements to produce a very simple report: a list of the top products in a pharmacy and their prices. You'll build two tables for the report: company header information and the product list. The example and data themselves are meaningless, but are used to demonstrate the construction of a simple report.

Figure 4: Establish the schema definition with the report.
Before you build the report layout in Crystal Reports, you must define a data schema to be used with the report. You will build an XML schema definition by creating a typed DataSet using Visual Studio .NET. Figure 3 shows the DataSet (DS_ProductList) containing the two data tables that you'll pass on to Crystal Reports as the report data definition. After you save the XML schema (DS_ProductList.XSD), you can open up Crystal Reports and start a new report. You have the option to either use the report wizard or create a blank report. I usually choose the second option. Crystal Reports then prompts you to specify the data source. Choose Create New Connection and expand the ADO.NET (XML) option. Crystal Reports then allows you to specify the XSD file that you created in Visual Studio .NET. After you select the XSD, you can select all of the datatables from the XSD (see Figure 4).

Figure 5: The Crystal Reports Field Explorer is a useful tool.
Once you've supplied the data schema to the report, you can drag and drop the data elements onto the report body, according to your needs. By clicking View...Field Explorer, the Crystal Reports Field Explorer appears (see Figure 5). The Field Explorer shows all of the available data elements, as well as valuable system data elements that you can use on a report (page X of Y, print date/time, etc.). After you design the report, you'll save it as RPT_ProductList.RPT. It's beyond the scope of this article to talk about all the great functions in Crystal Reports for building reports. Crystal Reports 10, in particular, has added some new power designer tools that make advanced report creation even easier. A good reference is Special Edition Using Crystal Reports 10, by Neil Fitzgerald, ISBN 0789731134.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date