ActiveReports 报表应用教程 (7)---交叉报表及数据透视图实现方案

在葡萄城ActiveReports报表中可以通过矩阵控件非常方便的实现交叉报表,同时还可以设置数据的分组、排序、过滤、小计、合计等操作,可以满足您报表的智能数据分析等需求。在矩阵控件中组的行数和列数由每个行分组和列分组中的唯一值的个数确定。同时,您可以按行组和列组中的多个字段或表达式对数据进行分组。在运行时,当组合报表数据和数据区域时,随着为列组添加列和为行组添加行,矩阵将在页面上水平和垂直增长。

在矩阵控件中,也可以包括最初隐藏详细信息数据的明细切换,然后用户便可单击该切换以根据需要显示更多或更少的详细信息,以此实现数据向下钻取功能。

我们这里将要演示的是产品销售数据分析表,列分组按照产品类别和产品名称进行分组;行分组按照年和月进行分组,并对销量大于2000的数据进行高亮显示,以下是详细实现步骤:

1、创建报表文件

在应用程序中创建一个名为 rptCrossTable1.rdlx 的 ActiveReports 报表文件,使用的项目模板为葡萄城ActiveReports报表页面报表,创建完成之后从 VS 的报表菜单项中选择转换为连续页面布局(CPL)报表,将固定页面报表转换为连续页面报表。

2、打开报表资源管理器,并按照以下信息创建报表数据源

名称:NWind_CHS
类型:Micorsoft OleDb Provider
OLE DB 提供程序:Microsoft.Jet.OLEDB.4.0
服务器或文件名称:Data\NWind_CHS.mdb

 

ActiveReports 报表功能展示 页面报表数据源

3、 添加数据集

在新建的 NWind_CHS 数据源上鼠标右键并选择添加数据集菜单项,数据集信息如下:

常规-名称:SaleDetails

查询-查询:

SELECT

t.*, 类别.类别名称

FROM

(

SELECT

DATEPART("yyyy",订单.订购日期)

AS

订购年, DATEPART("m",订单.订购日期)

AS

订购月,类别.类别ID,产品.产品名称,订单明细.数量, 订单明细.单价, 订单明细.折扣

FROM

(( 订单

INNERJOIN

订单明细

ON

订单.订单ID = 订单明细.订单ID)

INNERJOIN

产品

ON

订单明细.产品ID = 产品.产品ID)

INNERJOIN

类别

ON

产品.类别ID = 类别.类别ID )

as

t

INNERJOIN

类别

ON

t.类别ID = 类别.类别ID

ORDERBY

订购年,订购月

 

 

4、设计报表界面

从 Visual Studio 工具箱中将 ActiveReports 7 页面布局报表分类下的 Matrix 控件添加到报表设计界面,然后从属性窗口的命令区域选择属性对话框命令,以打开矩阵控件 Matrix 的属性设置对话框,然后按照以下表格设置矩阵控件 Matrix 的属性:

矩阵-常规-数据集名称:SaleDetails
行分组-常规-添加分组:名称:Matrix1_订购年
分组:=[订购年]
表达式:=[订购年]
行分组-常规-添加分组:名称:Matrix1_订购月
分组:=[订购月]
表达式:=[订购月]
列分组-常规-添加分组:名称:Matrix1_类别名称
分组:=[类别名称]
表达式:=[类别名称]
列分组-常规-添加分组:名称:Matrix1_产品名称
分组:=[产品名称]
表达式:=[产品名称]

 

完成以上设置之后回到报表设计界面,选中数据单元格 TextBox4 ,在属性窗口的命令区域中点击属性对话框命令,并按照以下表格设置数据单元格的属性:

常规-值:=Sum([数量] *[单价] * (1-[折扣]))
外观-背景色-颜色:=IIf( (Sum( [数量] *  [单价]  * (1-  [折扣]  )) > 2000) And ( Sum( [数量] *  [单价]  * (1-  [折扣]  )) <> ""  , "#c21952", "White" )

 

需要注意的是,我们将外观-背景色-颜色属性通过表达式的方式来完成对数据的高亮显示,如果销售量大于2000单元格背景色设置为高亮,小于等于2000设置为白色。

最终完成的设计界面如下:

ActiveReports 报表功能展示 交叉报表

 

5、运行程序

通过 F5 键运行程序,得到以下效果:

 ActiveReports 报表功能展示 交叉报表

在线演示及源码下载地址:


http://www.gcpowertools.com.cn/products/activereports_demo.htm
ActiveReports 报表功能展示

相关阅读:

【报表福利大放送】100余套报表模板免费下载 

 矩表 - 现代数据分析中必不可少的报表工具

 

转载于:https://www.cnblogs.com/powertoolsteam/p/3167297.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ActiveReports 7 2013 V1 1/4 共四个压缩文件,请全部下载后解压 Award-winning .NET reporting tool for Silverlight, Windows Forms, ASP.NET, and Windows Azure with an end-user Report Designer, Visual Studio integration, and more. Multi-platform Reporting Component with Pure Power The award-winning .NET reporting tool for Silverlight, Windows Forms, ASP.NET, and Windows Azure provides Microsoft .NET developers with familiar Visual Studio integrated designers and components, as well as an extensive API. Create reports ranging in functionality from form-based reports such as invoices and insurance documents, to transaction reports such as sales and accounting, to analytical reports such as sales and budget analysis and portfolio analysis. * ActiveReports joined the ComponentOne product line on July 1, 2012, when ComponentOne became a division of GrapeCity. See what's new in the ActiveReports 7 release! Why Choose ActiveReports 7? Multiple Report Types to Fit Your Reporting Needs Fixed Page Layout gives developers a new way of creating reports where layout is the primary focus. Great for creating invoices, prospectus reports, forms, or other highly structured reports. Continuous Page Layout makes it easy to create reports using tables, crosstabs, charts, and other data regions with flexible layouts. Section Reports follow the tradition of previous ActiveReports versions and are similar to Access reports. Using code-behind or scripts, you can respond to the various events that occur while the report generates to create extremely customized reports that are hard to produce with other products. Fast .NET Reporting Engine Fast .NET Reporting Engine ActiveReports 7 is optimized for speed. Its unique architecture allows the lean reporting engine to quickly read records from the data source and immediately render them to the output device. The simplicity of the design allows the data to pass through quickly from processing to rendering. Flexible .NET API The extensive ActiveReports 7 API allows Visual Basic and C# developers to completely control the report processing engine to fit their needs. Events and properties control: Data retrieval Data transformation Layout Rendering In addition, the API gives the developer complete control over the rendered document to allow selective printing or export, post-render drawing or stamping on pages, n-page, and booklet printing. For added control, ActiveReports 7 provides unmanaged access to the print job, allowing tray selection and duplex printer management as the document is rendered to the printer. Data Visualization and Layout Data Visualization and Layout Whether you need a simple listing or groups with keep-together control, master-detail reports, sub-reports, horizontal and vertical multi-column reports, address labels and badges, or richly formatted letters with mail merge support, ActiveReports is the solution. Simple and lightweight report controls allow you to easily create dazzling reports. With a selection including textbox, checkbox, line, shape, cross-section box, image, formatted text with mail merge, barcode (2D and 3D), chart, and other data visualization controls, they support a wide range of business reports. You can create reports of any size with nearly endless layout options. Rich Data Binding Rich Data Binding .NET data sources allow you to connect to any of the standard databases, plus .NET in-memory objects and collections. In addition, unbound data mode opens up the report to data from anywhere, in any form. If your application can access it, so can the report engine. Visual Studio Integrated Design Time Visual Studio Integrated Design Time The ActiveReports 7 report designer integrates with the Microsoft Visual Studio IDE allowing C# and Visual Basic developers to create reports and compile them into their Windows Forms, ASP.NET, and Silverlight applications. ActiveReports Professional Edition users can also use the royalty-free end-user report designer control to give similar report design functionality to end users within the business application. Cross-platform Support Cross-platform Support ActiveReports 7 offers versatile viewers to extend the reach of your reports to every platform. Built-in report viewers include Windows Forms, Adobe Flash, Microsoft Silverlight, and a rich HTML viewer, all with built-in search functions, hyperlink interaction, a table of contents, and multi-page zoom view support. ActiveReports includes Adobe PDF export with advanced encryption and international font support, Microsoft Excel export, and Rich Text Format (RTF) export. The extensive API allows fine control over the exported documents and their properties. The ActiveReports reporting engine supports cloud computing on Microsoft's Windows Azure platform under partial trust as well as full trust. Support for Migration from Other Reporting Tools Support for Migration from Other Reporting Tools ActiveReports 7 helps you preserve your past investments with easy report conversion from Microsoft Access and SAP Crystal Reports, thus greatly reducing the effort involved in recreating old reports when you migrate. No need to start from scratch! Global Options and Localization Support Global Options and Localization Support Localize the ActiveReports user interface to meet the needs of all of your international users. (There are fully localized Chinese and Japanese versions for those specific markets.) Localization also extends to the reports themselves: the reporting engine can use locale-specific text and formatting without the need to create multiple reports. Deployment Deployment ActiveReports 7 uses XCOPY deployment, making installation of your applications incredibly simple. There are no special merge modules to include, no licensing servers to install alongside your application, and no onerous activation procedures to go through.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值