In ActiveReports, you can easily implement cross-report using the matrix control, and Set Data grouping, sorting, filtering, subtotal, and aggregate operations, it can meet intelligent data analysis and other requirements of your reports. In the matrix control, the number of rows and columns in a group are determined by the number of unique values in each row group and column group. At the same time, you can group data by multiple fields or expressions in the row group and column group. During running, when you combine the report data and data areas, the matrix grows horizontally and vertically on the page as you add columns to the column group and Add rows to the row group.
In the matrix control, you can also include detailed switching of hidden detailed data. Then, you can click this switch to display more or less detailed information as needed, this allows you to drill down data.
Here we will demonstrate the product sales data analysis table. The column groups are grouped by product category and product name. The row groups are grouped by year and month, the data with sales volume greater than 2000 is highlighted. The detailed implementation steps are as follows:
1. Create a report file
Create an ActiveReports report file named rptCrossTable1.rdlx in the application. The project template used is the ActiveReports page report, after creation, select a continuous page layout (CPL) Report from the report menu of VS to convert a fixed page report to a continuous page report.
2. Open the report resource manager and create a report data source according to the following information:
Name: |
NWind_CHS |
Type: |
Micorsoft OleDb Provider |
Ole db Provider: |
Microsoft. Jet. OLEDB.4.0 |
Server or file name: |
Data \ NWind_CHS.mdb |
650) this. width = 650; "width =" 648 "height =" 580 "title =" ActiveReports report function display page report data source "style =" border-width: 0px; display: inline; "alt =" ActiveReports report function display page report data source "src =" http://www.bkjia.com/uploads/allimg/131228/20454050O-0.png "border =" 0 "/>
3. Add a dataset
Right-click the new NWind_CHS data source and choose add dataset from the shortcut menu. The dataset information is as follows:
General-Name: SaleDetails
Query-query:
SELECT
T. *, category. category name
FROM
(
SELECT
DATEPART ("yyyy", Order. Order Date)
AS
Subscription year, DATEPART ("m", Order. Order Date)
AS
Subscription month, category. Category ID, product. Product Name, order details, quantity, order details, unit price, order details, discount
FROM
(Order
INNERJOIN
Order Details
ON
Order. Order ID = order details. Order ID)
INNERJOIN
Product
ON
Order details. Product ID = product. Product ID)
INNERJOIN
Category
ON
Product. Category ID = category. Category ID)
as
T
INNERJOIN
Category
ON
T. Category ID = category. Category ID
ORDERBY
Subscription year, subscription month
4. design the report page
In the Visual Studio toolbox, add the Matrix control under the report category in the layout of ActiveReports 7 page to the report design page. Then, select the attribute dialog box command from the command area in the Properties window, to open the attribute Setting dialog box of the Matrix control Matrix, and then set the attributes of the Matrix control Matrix according to the following table:
Matrix-General-dataset Name: |
SaleDetails |
Row group-General-add group: |
Name: Matrix1 _ subscription year GROUP: = [subscription year] Expression: = [subscription year] |
Row group-General-add group: |
Name: Matrix1 _ subscription month GROUP: = [subscription month] Expression: = [subscription month] |
Column group-General-add group: |
Name: Matrix1 _ category name GROUP: = [category name] Expression: = [category name] |
Column group-General-add group: |
Name: Matrix1 _ Product Name GROUP: = [product name] Expression: = [product name] |
After completing the preceding settings, return to the report design page, select the data cell TextBox4, click the Properties dialog box command in the Command Area of the Properties window, and set the properties of the Data cell according to the following table:
General-value: |
= Sum ([quantity] * [unit price] * (1-[discount]) |
Appearance-background color-color: |
= IIf (Sum ([quantity] * [unit price] * (1-[discount])> 2000) and (Sum ([quantity] * [unit price] * (1-[discount]) <> "", "# c21952", "White ") |
Note that the appearance-background color-color attribute is highlighted by expression. If the sales volume is greater than 2000 cells, the background color is set to highlighted, set to white if the value is less than or equal to 2000.
The final design interface is as follows:
650) this. width = 650; "width =" 643 "height =" 354 "title =" ActiveReports report function display cross Report "style =" border-width: 0px; display: inline; "alt =" ActiveReports report function show cross Report "src =" http://www.bkjia.com/uploads/allimg/131228/2045405112-1.png "border =" 0 "/>
5. Run the program
Run the program by pressing F5 to get the following results:
650) this. width = 650; "width =" 644 "height =" 461 "title =" ActiveReports report function display cross Report "style =" border-width: 0px; display: inline; "alt =" ActiveReports report function show cross Report "src =" http://www.bkjia.com/uploads/allimg/131228/2045404624-2.png "border =" 0 "/>
Online Demo and source code:
Http://www.gcpowertools.com.cn/products/activereports_demo.htm
650) this. width = 650; "width =" 644 "height =" 516 "title =" ActiveReports report function display "style =" border-width: 0px; display: inline; "alt =" ActiveReports report function display "src =" http://www.bkjia.com/uploads/allimg/131228/2045405503-3.jpg "border =" 0 "/>
This article from the "grape city control blog" blog, please be sure to keep this source http://powertoolsteam.blog.51cto.com/2369428/1255838