Office 2000 Web Components3

编程模型要点

 

         本节中的各表是透视表组件编程模型要点的一个快速参考。当使用透视表控件编写程序时,可以参考本章了解应该使用什么属性,方法和事件。

41。绑定到数据

属性

解释

PivotTable.ConnectionString

应将这个属性设置为一个有效的连接字符串,可使透视表控件连接到数据源上。

PivotTable.CommandText

将这个属性设置为一个SQL语句,或任何提供者可接受的命令。该属性仅用于表列数据源。

PivotTable.DataMember

将这个属性设置为要使用的OLAP cube的名称,或是DataSource属性所引用的DSC中的数据集的名称。

PivotTable.DataSource

将这个属性设置为DSC的一个实例,之后就可以将它用作数据源了。即使您使用ConnectionString属性来连接数据源,DataSource属性也会返回一个DSC对象。

4-2. 调整、保存视图布局

属性或方法

解释

PivotView.Fieldsets

这个属性包含报表中可用的所有有效字段集。

PivotView.Totals

这个属性包含报表中可用的所有有效合计值。

InsertFieldset

使用这个方法在行轴、列轴或过滤轴上插入一个字段集。

PivotDataAxis.InsertTotal

在数据轴上使用这个方法可以将一个合计值插入到报表中。

PivotField.IsIncluded

将这个属性设置为False,可以将一字段集中的一个字段排除出报表。还可以使用这个属性来判断一个字段是否位于报表中。

Expanded

将这个属性设置为True,可以展开一个字段或成员,以显示它的子元素。读取这个属性的值,可以得知一个字段或成员当前是否处于被展开的状态。

PivotView.AutoLayout

使用这个方法可以为OLAP数据源清空视图,或为表列数据源将所有字段放置在细目区域中。

PivotView.AddTotal

使用这个方法根据一个细目字段创建一个新的合计值。

PivotField.SortDirection

使用这个属性来设置字段排序的方式,或获得字段当前的排序方向。

PivotField.SortOn

使用这个属性使字段的各成员根据它们的合计值排序,而不是根据它们的标题。

PivotField.SortOnScope

使用这个属性根据一个合计值对一系列成员进行排序,但只针对另一个轴上的一个范围内的成员进行排序(???)

PivotFieldset.FilterMember

使用这个属性来读取或设置过滤轴上的一个字段集中当前被选择的成员。

PivotField.FilterMembers

使用这个属性获得一个给定字段的当前过滤成员的集合

PivotField.FilterFunction

使用这个属性设置或判断FilterMembers属性所使用的过滤函数。过滤函数可以包含或排除成员,或是没有过滤动作。

PivotTable.XMLData

使用这个属性来获得当前报表的定义信息,它是一个巨大的字符串,您可以保存这个字符串,并在将来读取它,并重新设置报表。

PivotView.TotalOrientation

使用这个属性来使透视表控件将行标题显示为合计值的标题,而不是列标题。

PivotGroupAxis.DisplayEmptyMembers

使用这个属性强迫透视表控件显示完全没有数据的行或列。

4-3. 定制、格式化视图。

属性

解释

PivotTable.AutoFit

使用这个属性来关闭AutoFit特性,在一个基于表单的环境中(例如VB)尤其有用。

PivotView.TitleBar

使用这个属性来调整标题条的文字和格式。

PivotTable.DisplayToolbar,
PivotTable.DisplayFieldList,
PivotTable.DisplayPropertyToolbox

使用这些属性来控制工具条、字段列表、和属性工具箱这些元素是否可视。

PivotTotal.NumberFormat

使用这些属性来格式化合计值的数字。

PivotField.SubtotalBackColor

使用这个属性来设置小计的背景色,使得小计和那些组成小计的数字显得不同。当一个大报表中需要在视觉上区别不同级别的合计值时,SubtotalBackColor属性十分有用。

PivotField.SubtotalFont

利用这个属性,可以使小计的字体和组成小计的数字的字体不同。

PivotTable.MemberExpand

使用这个属性使透视表控件在将字段和成员添加到视图中自动展开它们。

4-4. 重要的事件。

事件

解释

QueryComplete

当透视表控件在数据源上执行了一个查询后触发该事件,通常发生该事件时应该改变报表的布局。这是一个调整报表标题,以及任何其它需要和报表同步的用户界面元素的好机会。

Click

当用户在报表上点击时触发。请使用Selection属性来判断用户点击了哪里。

DblClick

Click事件相似,但是是在用户双击时触发。常用来触发一个跳转,转到另一页以显示组成一个汇总值的细目信息,也可用来显示属性工具箱,或显示您自定义格式的用户界面。

SelectionChange

当报表中被选择的部分改变时触发。主要用于当选择了新的数值时,需要改变页面或窗体上的其它元素的情况。

PivotTableChange

在使用表列数据源时,会有多种原因触发该事件。事件的参数Reason说明了触发事件的原因,比如说,创建了一个新的汇总值,或删除了一个汇总值。

ViewChange

该事件会被频繁的触发,因此不应在该事件处理函数中处理太多的任务。视图中任何一点轻微的改动都可能触发该事件;事件参数Reason说明了具体发生了什么。请参考OWC联机帮助文件(Msowcvba.chm)中的枚举PivotViewReasonEnum,它包含了触发该事件的各种原因的完整列表。

 

 

 

 

           

         本章包括了关于透视表组件的,许多开发者的常见问题的解答,因此阅读完本章后,您应该已经比较了解这项强大技术的各项功能了。下面在第七章中将讲述更多透视表组件的内容,在该章中将研究一个完整的OLAP销售分析和报表系统的源码。

 

 

 

 

附录:英文原文

 

Key Elements of the Programming Model

The tables in this section provide a quick synopsis of the key elements in the PivotTable component's programming model. When you sit down to write a new program using the PivotTable control, refer to this section for a reminder of what properties, methods, and events to use.

Table 4-1. Binding to data.

Property

Description

PivotTable.ConnectionString

Set this to a valid connection string to hook up the PivotTable control to the data source.

PivotTable.CommandText

Set this to a SQL statement or whatever command text the provider will accept. CommandText is used only for tabular data sources.

PivotTable.DataMember

Set this to the name of the OLAP cube you want to use or the name of the data set in the DSC referred to by the DataSource property.

PivotTable.DataSource

Set this to an instance of the DSC to use it as the data source. DataSource also will return the DSC even when you use the built-in ConnectionString property.

Table 4-2. Adjusting and saving the view layout.

Property or Method

Description

PivotView.Fieldsets

This property contains all available fieldsets that you can use in the report.

PivotView.Totals

This property contains all available totals that you can use in the report.

InsertFieldset

Use this method on the row, column, or filter axis to insert a fieldset on the axis.

PivotDataAxis.InsertTotal

Use this method on the data axis to insert a total into the report.

PivotField.IsIncluded

Set this property to False to leave a field of a fieldset out of the report. Use IsIncluded to determine whether the field is in the report.

Expanded

Set this property to True to expand a field or member and show its children. Retrieve the value of Expanded to determine whether a field or member is currently expanded.

PivotView.AutoLayout

Use this method to clear the view for an OLAP data source or to put all fields in the detail area for a tabular source.

PivotView.AddTotal

Use this method to create a new total from a detail field.

PivotField.SortDirection

Use this property to set which way a field should be sorted or to get the field's current sort order.

PivotField.SortOn

Use this property to make the field's members sort by their total values instead of by their captions.

PivotField.SortOnScope

Use this property to sort a set of members based on a total, but only for a certain scope of members on the other axis.

PivotFieldset.FilterMember

Use this property to get or set the currently selected member of a fieldset on the filter axis.

PivotField.FilterMembers

Use this property to get the current set of filtered members for a given field.

PivotField.FilterFunction

Use this property to set or determine the filter function being used with the FilterMembers property. The filter function can include or exclude members, or there might be no filtering.

PivotTable.XMLData

Use this property to retrieve the definition of the current report as a large string that you can save and later reset.

PivotView.TotalOrientation

Use this property to make the PivotTable control display the total captions as row headings instead of column headings.

PivotGroupAxis.DisplayEmptyMembers

Use this property to force the PivotTable control to display rows or columns that are completely empty.

Table 4-3. Customizing and formatting the view.

Property

Description

PivotTable.AutoFit

Use this property to turn off the AutoFit behavior, especially for a form-based environment such as Visual Basic.

PivotView.TitleBar

Use this property to adjust the title bar's caption and formatting.

PivotTable.DisplayToolbar,
PivotTable.DisplayFieldList,
PivotTable.DisplayPropertyToolbox

Use these properties to control visibility of elements such as the toolbar, field list, and Property Toolbox

PivotTotal.NumberFormat

Use this property to format the numbers of a total.

PivotField.SubtotalBackColor

Use this property to make the background color of a subtotal different than that of the numbers that contributed to the subtotal. SubtotalBackColor is useful for making a visual distinction among different levels of totals in a large report.

PivotField.SubtotalFont

Use this property to differentiate the font used for subtotals from the font used for the numbers that contributed to the subtotals.

PivotTable.MemberExpand

Use this property to make the PivotTable control automatically expand all fields and members when added to the view.

Table 4-4. Noteworthy events.

Event

Description

QueryComplete

Raised after the PivotTable control has executed a query against the data source, which is commonly a reaction to a change in the report's layout. This is a good time to adjust the report title and any other user interface elements that need to be synchronized with the report.

Click

Fired when a user clicks anywhere on the report. Use the Selection property to determine where.

DblClick

Same as Click, but is fired when the user double-clicks. Useful for triggering a jump to another page to show details behind an aggregate or perhaps to display the Property Toolbox or your own formatting user interface.

SelectionChange

Fired whenever the selection has changed in the report. Mostly useful when you have other elements on your page or form that should change when new values are selected.

PivotTableChange

Fired for various reasons when using a tabular data source. The Reason parameter tells you what happened, which includes events such as a new total being created or a total being deleted.

ViewChange

Fired often, so be careful about doing too much in the event handler. Any slight change in the view causes this event to fire; the Reason parameter indicates what happened. See PivotViewReasonEnum in the OWC online help file (Msowcvba.chm) for a complete list of reasons.

 

 

Summary

This chapter covered many of the questions that developers commonly ask about the PivotTable component, so you should now have a good understanding of the capabilities of this powerful piece of technology. Stay tuned for more about the PivotTable component in Chapter 7, where we will look at the source code for an OLAP sales analysis and reporting system.

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值