Crystal Reports for Visual Studio 2005 in CSharp - Exercise 6: Adding Charts and Summary Information to the Report (Page 5 of 5 ) Scenario
At this point, you have a fully functional web site that will display a Crystal report based off of an Object Collection. The site displays information that is programmatically entered into an Object Collection, as well as information that is added dynamically at run time. In this exercise, you will add two charts, a calculated field, and summary information. Tasks Detailed Steps Adding a simple chart to the report.
From the solution explorer, open StockObjects.rpt.
From the Crystal Reports menu, select Insert, and click Chart.
In the Chart Expert dialog box, select a Pie chart.
Select the Data tab.
Select Stock.Symbol and click the top most Right Arrow to move the Stock.Symbol field to the On Change Of field.
Select Stock.Volume and click the bottom most Right Arrow to move the Stock.Volume field to the Show Value(s) field.
Click OK.
A new Report Header section is created, and a chart object is added to this section.
From the Debug menu, click Start Debugging.
If no build errors appear, the Default.aspx page loads into your browser.
Close the Internet Explorer window.
Adding a chart based on a formula field. In this section, you will create a chart that reports off of aggregate information. You will first create a formula to calculate the worth of a particular holding, and then create a pie chart that displays the proportional worth of all of your holdings.
From the Crystal Reports menu, select Report, and click Formula Workshop.
In the Formula Workshop dialog, select Formula Fields.
Click the New button to create a new formula.
In the Formula Name dialog, enter worth.
Click Use Editor.
Add code to multiply the value of the price field by the value of the volume field.
{Stock.Volume}*{Stock.Price}
Click Save and close.
From the Crystal Reports menu, select Insert, and click Chart.
In the Chart Expert dialog box, select a Pie chart.
Click the Data tab.
Select Stock.Symbol and click the top most Right Arrow to move the Stock.Symbol field to the On Change Of field.
Select Worth and click the bottom most Right Arrow to move the Worth formula to the Show Value(s) field.
Click the Text tab.
Beside Title, clear the Auto-text checkbox.
Enter Worth / Symbol in the Title field.
Click OK.
A new Report Header section is created, and a Chart Object is added to this
section
To re-position the objects within a Crystal report, drag them with your mouse and place them where you like. You can use the Main Report Preview button at the bottom of the form to display a preview of your report.
Adding Formula and Summary fields to your report. In this section, you add a formula field to your report, and a summary field that will calculate the total value of your portfolio.
Expand the Formula Fields node of the Field Explorer. Drag the worth formula onto your report. Position this field within the Details section of your report.
If the Field Explorer is not visible, select Document Outline from the View menu. This field will display the worth of each row. Use a summary field to display the total worth of your portfolio. From the Crystal Reports menu, select Insert, and click Summary.
The Insert Summary dialog box appears. Select the Worth formula from the Choose the Field to Summarize field. Select Sum from the Calculate this Summary field. Select Grand Total from the Summary Location field. Click OK.
A summary field is added to the report. From the Debug menu, click Start Debugging. If no build errors appear, the Default.aspx page loads into your browser. Close the Internet Explorer window.
Adding a pre-existing report. In this section, you will set your Web Application to use an existing report located on your file system. Right click on StockObjects.rpt in the Solution Explorer. Click Delete. Click OK in the dialog that pops up. In Solution Explorer, right-click the web site name that is in bold type and then click Add Existing Item. In the Add Existing Item dialog, navigate to C:\Microsoft Hands-On-Lab\HOL-ILL05\Source\ Excercises and select the StockObjects.rpt file. Click Add. From the Debug menu, click Start Debugging. If no build errors appear, the Default.aspx page loads into your browser and displays your new report. Close the Internet Explorer window.
 | Take Microsoft software for a test drive. With MSDN Virtual Labs, you get full access to all available Microsoft products through 90-minute modules, each with its own downloadable manual. Try this lab out now. |
|