The CrossTabReport sample displays hierarchical information in a cross tabular structure. This sample consists of a StartForm with an ActiveReports Viewer control and a ProductWeeklySales report.
Sample Location
Visual Basic.NET
<User Folder>\Documents\GrapeCity Samples\ActiveReports 10\Section Reports\Layout\CrossTabReport\VB.NET
C#
<User Folder>\Documents\GrapeCity Samples\ActiveReports 10\Section Reports\Layout\CrossTabReport\C#
Runtime Features
When you run the sample, a report displaying a list of weekly sales for current week, month, quarter or year for each product category is displayed in the Viewer control. The values highlighted in red represent negative values.
Note: To run this sample, you must have access to the Nwind.mdb. A copy is located at [User Documents folder]\GrapeCity Samples\ActiveReports 10\Data\NWIND.mdb. If you are unable to access the data files in the sample, create the Data folder and place all the data files to this folder, or change the reference path to the data files within the folder according to your environment.
Project Details
StartForm
ProductWeeklySales Report
This report features a number of accumulated values using summary function property settings and calculated values in the code.
The summary function displays a list of summary values only for weekly sales total in group footer without displaying the Detail section. By setting the Height property of Detail section to 0 and/or hiding the Detail section by setting Visible property to False, you can create a summary report that only displays sections other than the Detail section.
Based on the order date of Detail section data, you can determine whether it will be included in a week, month, quarter, year or previous year's quarter and set the values by sorting in unbound fields. Value of each unbound field is automatically summarized by each Field placed in the group footer section.
ReportHeader section
This section of the report features static controls including Labels, a Picture, a Line, and a Shape control. The report header prints only once on the first page of the report, thus report title, company information, and a logo are added in this section.
PageHeader section
The page header section contains static Label controls that print at the top of each page and serve as column headers for the group header sections.
ghCategory section
This group header section has the DataField property set to CategoryName. This setting, along with data sorted by the same field, produces a report grouped by category. The section contains one bound TextBox control to display the category name at the beginning of each group. The section's UnderlayNext property is set to True so that the category prints to the left of the top line of data instead of above it.
ghProduct section
Although this group header contains no controls and is hidden by setting the Height property to 0 and Visible property to False, it still performs two important functions. First, the DataField property is set to ProductName, to sort the data inside each category by product, and second, the related group footer section displays the bulk of the data for the report.
Detail section
The detail section of this report is hidden by setting the Height property to 0 and Visible property to False, but it does contain four bound fields whose values are used in the code. In the Detail Format event, the value from the hidden txtDetProduct TextBox is collected and passed to the _sProductName variable. For more information on section events, see Section Report Events.
gfProduct section
This group footer section displays the bulk of the data for the report in TextBox controls that have values passed in code, or are bound to fields from the report's Fields collection (see FetchData and DataInitialize events in the code) using the DataField property.
In the gfProduct Format event for the inner group footer section, the product name collected from the Detail Format event is passed to the txtProduct TextBox. The Value for the txtPQTDChange TextBox is calculated by subtracting the prior year's quarter-to-date sales figure from the current quarter-to-date sales figure. The BackColor of the txtPQTDChange TextBox is set to Red if the value is negative.
The total units and sales for each product is summarized using the following properties.
gfCategory section
This group footer section displays totals of the gfProduct data in TextBox controls that have values passed in code, or are bound to fields from the report's Fields collection (see FetchData and DataInitialize events in the code) using the DataField property.
The total units and sales for each category is summarized using the following properties.
PageFooter section
This section is not used, so it is hidden by setting the Height property to 0 and/or Visible property to False. Otherwise, it would print at the bottom of each page. The section cannot be deleted, because the related PageHeader section is in use.
ReportFooter section
This section is not used, so it is hidden by setting the Height property to 0 and/or Visible property to False. Otherwise, it would print once at the end of the report. The section cannot be deleted, because its related ReportHeader section is in use.