ActiveReports Report Application Tutorial (15) --- Report Skinning

original
2014/06/11 12:00
Reading 411

In ActiveReports, you can set the styles of different controls in the report, and then save these styles to an external XML file for use by other reports. If users want the same report to be distributed with different appearances, they can simply modify the style form without changing the font, color, size, etc. of individual controls in each report one by one.

This article shows how to set different skin styles for the annual sales statistics table. We have prepared three skin styles. The following are the detailed steps:

1. Create Report File

Create an ActiveReports report file named rptTheme1.rdlx in the application. The project template used is an ActiveReports page report. After creation, select Convert to Continuous Page Layout (CPL) report from the VS report menu item to convert a fixed page report to a continuous page report.

2. Open Report Explorer 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

3. Add Dataset

Right click the new NWind_CHS data source and select Add Dataset to add the following two datasets:

General - Name: Sales

Query - Query:

 SELECT

Category. Category Name, Order. Owner Region,

 SUM

(Order details. Quantity)

 AS

Sales volume

 FROM

(Order

 INNER JOIN

Order Details

 ON

Order. Order ID=Order Details. Order ID)

 INNER JOIN

Product

 ON

Order details. Product ID=Product. Product ID)

 INNER JOIN

Category

 ON

Product.category ID=category.category ID

 WHERE

DATEDIFF(" yyyy ", Order. Order date, ' 2011-01-01 ') = 0

 GROUP BY

Category. Category Name, Order. Owner Region

 ORDER BY

Category. Category Name, Order. Owner Region

 

General - Name: SaleDetails

Query - Query:

 SELECT

DATEPART(" m ", Order. Order Date)

 AS

Subscription month, category. Category name,

 SUM

(Order details. Quantity)

 AS

Sales volume

 FROM

(Order

 INNER JOIN

Order Details

 ON

Order. Order ID=Order Details. Order ID)

 INNER JOIN

Product

 ON

Order details. Product ID=Product. Product ID)

 INNER JOIN

Category

 ON

Product.category ID=category.category ID

 WHERE

DATEDIFF(" yyyy ", Order. Order date, ' 2011-01-01 ') = 0

 GROUP BY

DATEPART(" m ", Order. Order Date), Category.CategoryID, Category.CategoryName

 ORDER BY

DATEPART(" m ", Order. Order Date), Category.CategoryID, Category.CategoryName

 

4. Design report interface

4.1 Create three theme styles in the GrapeCity ActiveReports theme editor

Style1.rdlx-theme

 ActiveReports report function display theme skin

 

Style2.rdlx-theme

 ActiveReports report function display theme skin

 

Style3.rdlx-theme

 ActiveReports report function display theme skin

After the above theme style is created, specify a theme for the report. The theme style we specified during design is Style1

 ActiveReports report function display theme skin

4.2. Create annual sales statistics of each region

Add the Chart control to the report design interface from the Visual Studio toolbox, and set the properties of the Chart control according to the following list

Chart Data Properties Dialog Box:

General - Dataset name: Sales
Series Value - Value: =Sum ([sales volume])
Category grouping: Name: Chart1_CategoryGroup1
Grouping - Expression:=[Category Name]
Label:=[Category Name]
Series grouping: Name: Chart1_SeriesGroup1
Grouping - Expression:=[Owner Region]
Label:=[Shipper's Region]

 

Chart Appearance Properties Dialog Box:

Type: Chart Type: Line Chart
Subtype: smooth
Title: Statistical Table of Sales Volume by Region in 2011
Palette:
=Theme. Colors.Accent1 
=Theme. Colors.Accent2 
=Theme. Colors.Accent3 
=Theme. Colors.Accent4 
=Theme. Colors.Accent5

 

4.3. Create a sales map for each region

Add the Chart control to the report design interface from the Visual Studio toolbox, and set the properties of the Chart control according to the following list

Chart Data Properties Dialog Box:

Chart Attribute Name Attribute value
Sales in Northeast China General: Dataset name: Sales
Series values: Value:=Sum ([sales volume])
Category grouping: Name: Chart2_CategoryGroup1
Expression:=[Category Name]
Label:=[Category Name]
Filtering: Expression:=[Owner Region]
Operator: Equal
Value: Northeast

 

Chart Appearance Properties Dialog Box:

Type: Chart type: height chart
Palette: =Theme. Colors.Accent1
=Theme. Colors.Accent2 
=Theme. Colors.Accent3 
=Theme. Colors.Accent4 
=Theme. Colors.Accent5 
=Theme. Colors.Accent6 
=Theme. Colors.Hyperlink 
=Theme. Colors.HyperlinkFollowed

 

4.4. Repeat 4.3 to create sales charts for four regions: North China, East China, South China, and Southwest. The chart area depends on the value of filter conditions.

The final design structure is shown below:

 ActiveReports report function display theme skin

5. Dynamically load user specified theme styles in background code

GrapeCity.ActiveReports.PageReport report = new  GrapeCity. ActiveReports.PageReport( new  System. IO.FileInfo(Server. MapPath(" ../Reports/ " + reportname + " .rdlx ")));  report. Report.DataSources[0]. DataSourceReference = "";  report. Report.DataSources[0]. ConnectionProperties.DataProvider = " OLEDB ";  report. Report.DataSources[0]. ConnectionProperties.ConnectString =  string .Format(" Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}; ", Server.MapPath(" ../Data/NWind_CHS.mdb "));  report. Report.Themes.Clear();  report. Report.Themes.Add(Server. MapPath( string .Format(" ../Theme/Style{0}.rdlx-theme ", themeid)));  WebViewer1.Report = report;

 

6. Run program

 ActiveReports report function shows switching theme skin

Online demonstration and source code download address:


http://www.gcpowertools.com.cn/products/activereports_demo.htm
 ActiveReports report function display

This article is from“ Grapevine Control Blog ”Blog, please keep this source http://powertoolsteam.blog.51cto.com/2369428/1255873

Expand to read the full text
Loading
Click to lead the topic 📣 Post and join the discussion 🔥
Reward
zero comment
zero Collection
zero fabulous
 Back to top
Top