ActiveReports使用指南--创建年度报表

上传人:宝路 文档编号:2138803 上传时间:2017-07-20 格式:DOCX 页数:6 大小:175.38KB
返回 下载 相关 举报
ActiveReports使用指南--创建年度报表_第1页
第1页 / 共6页
ActiveReports使用指南--创建年度报表_第2页
第2页 / 共6页
ActiveReports使用指南--创建年度报表_第3页
第3页 / 共6页
ActiveReports使用指南--创建年度报表_第4页
第4页 / 共6页
ActiveReports使用指南--创建年度报表_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《ActiveReports使用指南--创建年度报表》由会员分享,可在线阅读,更多相关《ActiveReports使用指南--创建年度报表(6页珍藏版)》请在金锄头文库上搜索。

1、慧都控件网慧都控件网ActiveReports 使用指南-创建年度报表用户可以在 ActiveReports 的 Sample 中找到 Annual Report,大家可以通过运行此用例,配合以下文字介绍,学习到如何使用子报表,区域属性,以及图表控件来快速的建立一个年度报表。以下按照 Solution Explorer 窗口里的文件逐个介绍。1. 年度报表(主报表)以下介绍的是主报表的建立, 此年度报表分为三页, 缩影如下图。a) 报表页眉区域(第一,二页)在这次介绍的示例中, 我们的报表页眉区域分为两页。 这里通过使用PageBreak 控件将 ReportHeader 分成两页, 并且将

2、ReportHeader 区域的NewPage 属性设置为 After. 另外, 这个报表会告诉用户可以使用 Label 的BackColor 和 ForeColor 属性建立需要区域视觉分辨性强的报表。这个报表的 ReportHeader 区域安插了 SubReport 控件, 在 ReportStart 事件里, 使用程序编译连接至 ProductSalesByCategory 报表。建议在 ReportStart 事件中初始化报表, 而并非是在每个区域的 Format 事件。CSharp: private void AnnualReport_ReportStart(object send

3、er, System.EventArgseArgs)/Set subreport controls Report property to a new report instancethis.srptTop10.Report = new Top10();this.srptProductSales.Report = new ProductSalesByCategory();慧都控件网慧都控件网VB:Private Sub AnnualReport_ReportStart(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyB

4、ase.ReportStartSet subreport controls Report property to a new report instanceMe.srptTop10.Report = New Top10()Me.srptProductSales.Report = New ProductSalesByCategory()End SubReportHeader 区域右半部分黄色背景的, 使用的是 Shape 控件, 通过BackColor 属性设置颜色。 左半边则使用了 Picture 控件。b) Detail Section 明细区域(第三页)明细区域包含两个 SubReport

5、 控件,分别连接为 Top10Customers 和Top10Products 报表。通常,在很多报表中,明细区 域会运行很多次;但在此报表中,明细区域只有 Label,而并无绑定的数据,因此只会运行一次。这样的话,两个子报表就可以在 ReportStart 事件 中被初始化。慧都控件网慧都控件网注意:请将 ReportFooter 区域的是 Height 属性设置为 0. 这是因为,除了明细区域,页眉页脚区域在一页中是同时出现的,如果不想使用页脚,则需要将其高度设置为 0,而并不能够单独删除页脚。c) GetDBPath 获取数据源对于数据库的连接,在论坛上知识库与精华区“ActiveRep

6、orts 6.0 产品使用指南 (2)快速绑定数据源 ”中有详细的介绍。这里的示例使用的数据库依然为NorthWind。2. ProductSalesByCategory 报表这可以是一个单独的 ActiveReport,但在这个年度报表示例中被使用为SubReport,其放置的区域为 ReportHeader 区域(第二页报表的左下角)。 这里需要注意的是,如果建立的报表是为了使用为子报表,则这个子报表如无特别需要则不用建立页眉页脚区域,可将其ReportHeader/Footer 和 PageHeader/Footer 拿掉。这样会缩短报表运行的过程。 PrintWidth 属性只有 2.

7、677 英寸;这个宽度正好与主报表中 SubReport控件匹配。 这个报表在 GroupHeader 区域使用 Labels 来呈现数据名称,在明细区域逐条打印数据。慧都控件网慧都控件网 在报表周围的灰色区域, 右击选择 ViewCode,可以查看编译的程序,包括数据库的绑定, 各背景色彩的设定。CSharp: private void ProductSalesByCategory_DataInitialize(object sender, System.EventArgseArgs)/Create dynamic datasource using sample databaseDataDy

8、namics.ActiveReports.DataSources.OleDBDataSource _ds = new DataDynamics.ActiveReports.DataSources.OleDBDataSource();_ds.ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source= + GetDBPath.GetPath() + nwind.mdb;_ds.SQL = SELECT DISTINCTROW Categories.CategoryName,

9、 Sum(Order Details Extended.ExtendedPrice) AS ProductSales FROM Categories INNER JOIN (Products INNER JOIN (Orders INNER JOIN Order Details Extended ON Orders.OrderID = Order Details Extended.OrderID) ON Products.ProductID = Order Details Extended.ProductID) ON Categories.CategoryID = Products.Categ

10、oryID WHERE (Orders.OrderDate) Between #1/1/95# And #12/31/95#) GROUP BY Categories.CategoryName ORDER BY Categories.CategoryName;this.DataSource = _ds;private void Detail_Format(object sender, System.EventArgseArgs)/ Check _iRow value to see if we need to highlight the row or not.if(this._iRow%2 =

11、0)this.Detail.BackColor = Color.LightYellow; elsethis.Detail.BackColor = Color.Transparent;this._iRow+;VB:Private Sub ProductSalesByCategory_DataInitialize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.DataInitializeCreate dynamic datasource using sample databaseDim _ds As New

12、DataDynamics.ActiveReports.DataSources.OleDBDataSource()_ds.ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source= + GetDBPath.GetPath() + nwind.mdb_ds.SQL = SELECT DISTINCTROW Categories.CategoryName, Sum(Order Details Extended.ExtendedPrice) AS ProductSales FR

13、OM Categories 慧都控件网慧都控件网INNER JOIN (Products INNER JOIN (Orders INNER JOIN Order Details Extended ON Orders.OrderID = Order Details Extended.OrderID) ON Products.ProductID = Order Details Extended.ProductID) ON Categories.CategoryID = Products.CategoryID WHERE (Orders.OrderDate) Between #1/1/95# And

14、 #12/31/95#) GROUP BY Categories.CategoryName ORDER BY Categories.CategoryNameMe.DataSource = _dsEnd SubPrivate Sub Detail_Format(ByVal sender As Object, ByVal e As System.EventArgs) Handles Detail.Format Check _iRow value to see if we need to highlight the row or not.If Me._iRow Mod 2 = 0 ThenMe.De

15、tail.BackColor = Color.LightYellowElseMe.Detail.BackColor = Color.TransparentEnd IfMe._iRow = Me._iRow + 1End Sub3. StartupForm 起始表格这个表格使用了 ActiveReports 的 Viewer 控件。 将 Viewer 的 Dock 属性设置为 Fill,表格在运行时便会自动调整大小。 用户可以右击选择ViewCode 来查看程序。4. Top10Customers 报表和 Top10Products报表Top10Customers 和 Top10Products

16、 两个报表都各自只有两个区域,即GroupHeader 和 Detail。请将两个报表的PrintWidth 属性设置为 3.135 inches, 这样两个报表的大小正好合适于主报表。这两个子报表的 GroupHeader 区域都被 Chart 控件填充着。大家可以点击图表,查看一下这个图表属性的设置。在属性窗口的下方,点击蓝色 的 Data Source,图表绑定的数据源窗口会弹出,在 Query 框中,可以查看到如何选择前 10 位的SQL 语句。对于如何在 ActiveReports中建立图 表,我们会在下一个主题中详细介绍)。慧都控件网慧都控件网在每个子报表的明细区域,设置两个 TextBoxes 和一个 Label 控件, 可以右击,选择ViewCode 来查看如何设置数据源, 传递数据到图表上, 以及交替设置明细部分的背景色, 以及如何设置 Label 的 Text 属性。

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号