Translator's description: Welcome to my blog: http://blog.9cbs.net/daidaoke2001/
The mistakes in the translation or improper look at it, this is also the greatest driving force I insist on the translation work.
My email: tangtaike@163.com
For reprint, please notify us in advance.
Programming model points
The various tables in this section are a quick reference to the point of view of the perspective table component programming model. When using a Pivot table control writing program, you can refer to this chapter to learn what properties, methods, and events should be used.
Table 4-1. Bind to data
Attributes
Explanation
Pivottable.connectionstring
This property should be set to a valid connection string that allows the perspective control to connect to the data source.
Pivottable.commandtext
Set this property to a SQL statement, or any provider acceptable command. This attribute is only used for table column data sources.
Pivottable.datamember
Set this property to the name of the OLAP Cube to use, or the name of the DSC in the DSC referenced by the DataSource property.
Pivottable.DataSource
Set this property to an instance of the DSC, then you can use it as a data source. Even if you use the Connectionstring property to connect the data source, the DataSource property will return a DSC object.
Table 4-2. Adjust, save view layout.
Attribute or method
Explanation
PivotView.fieldsets
This property contains all valid fields available in the report.
PivotView.Totals
This property contains all valid consolidations available in the report.
INSERTFIELDSET
Use this method to insert a field set on the row axis, column axis or filter axis.
PivotdataAxis.Insrttotal
Using this method on the data axis can insert a matching value into the report.
Pivotfield.isinCluded
Set this property to false, you can exclude a field in a field in a field. You can also use this attribute to determine if a field is in the report.
Expanded
Set this property to True, you can expand a field or member to display its child elements. Read the value of this property, you can know if a field or member is currently in the deployed state.
PivotView.AutoLayout
Using this method can be empty for the OLAP data source, or place all fields in the discounted area for the table column data source.
PivotView.Addtotal
Use this method to create a new total value according to a discipline field.
Pivotfield.sortdirection
Use this property to set the field sorting, or get the current sorting direction of the field.
Pivotfield.sorton
Use this property to make the members of the field sorted according to their total value, not based on their headings.
Pivotfield.sortonscope
Use this property to sort a series of members according to a single value, but only for members within one range on another axis (???)
PivotfieldSet.FilterMember
Use this property to read or set a field that is currently selected in the filter axis.
Pivotfield.FilterMembers
Use this attribute to get a collection of current filtering members of a given field
Pivotfield.FilterFunction
Use this property to set or determine the filter function used by the FilterMembers property. Filtering function can contain or exclude members, or there is no filtering.
Pivottable.xmldata
Use this property to get the definition information of the current report, it is a huge string, you can save this string and read it in the future, and reset the report.
PivotView.TotalorIntation
Use this property to make the Pivot table control to display the tab of the total value instead of column headings. Pivotgroupaxis.displayemptymembers
Use this property to force the perspective control to display a row or column that is completely no data.
Table 4-3. Customized, format view.
Attributes
Explanation
Pivottable.autofit
Use this property to turn off the Autofit feature, especially useful in a form-based environment (eg, VB).
PivotView.Titlebar
Use this property to adjust the text and format of the title bar.
Pivottable.displayToolbar, Pivottable.displayFieldList, Pivottable.DisplayPropertyToolbox
Use these attributes to control the toolbar, field list, and attribute toolboxes.
Pivottotal.NumberFormat
Use these properties to format the numbers of the values.
Pivotfield.subtotalbackColor
Use this attribute to set the small background color so that the small counts and the numeric numbers that make up a small meter are different. SubtotalbackColor properties are useful when you need a total value of different levels in a big report.
Pivotfield.subtotalFont
With this property, the fonts of the small fonts and the fonts that make up a small number can be different.
Pivottable.memberexpand
Use this property to enable Pivot table controls to automatically expand them in a field and a member to the view.
Table 4-4. Important events.
event
Explanation
Querycomplete
When the perspective control is triggered after a query is executed on the data source, the layout of the report should be changed when the event occurs. This is a good opportunity to adjust report titles, as well as any other user interface element that needs to be synchronized.
Click
Trigger when the user clicks on the report. Please use the Selection property to determine where the user clicks.
DBLClick
Similar to the Click event, but triggered when the user doubles. Commonly used to trigger a jump, go to another page to display a breakdown information that makes up a summary value, or it can also be used to display the properties toolbox or display the user interface of your custom format.
SelectionChange
Triggered when the part selected in the report changes. Mainly used to change the case of other elements on the page or form when new values are selected.
PivottableChange
When using the table column data source, there will be a variety of reasons to trigger the event. The parameter of the event refers to the reason for the triggering event, for example, a new summary value is created, or deletes a summary value.
Viewchange
This event will trigger frequently, so there should not handle too much task in the event handler. Any slight change in the view may trigger the event; the event parameter ison explained what happened. Please refer to the enumeration PivotViewReasonNum in the OWC online help file (msowcvba.chm), which contains a complete list of various reasons that triggered the event.
Small knot
This chapter includes answers to the common problem of the perspective, many developers, so after reading this chapter, you should have a comparison of the features of this powerful technology. The contents of more perspective table components will be described in Chapter VII, and a complete OLAP sales analysis and source code for reporting system will be studied in this chapter.
Appendix: English
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 WHATEER COMMAND TEXT The Provider Will Accept. CommandText IS Used Only for Tabular Data Source.
Pivottable.datamember
Set this to the name of the ip cube you want to use or the name of the data set in the dsc referred to by the datasource print.
Pivottable.DataSource
Set this to an instance of the datasource also will return the datasource also will return The dsc even when users.
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.Insrttotal
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 Dermine 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.............. ..
Pivotfield.sorton
Use this property to make the field's members Sort by Their Total Values INSTEAD OF BY THEIR CAPTIONS.
Pivotfield.sortonscope
Uses 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 successmed member of a fieldset on the filter axis.
Pivotfield.FilterMembers
Use this property to get the capital set of filtered members for a given field.
Pivotfield.FilterFunction
Uses Property TO SET OR DETERMINE THE FILTER FUNCLERTY. The filter function can include or the one might be no filtering.
Pivottable.xmldata
Uses Property to Retrieve The Definition of The Current Report As A Large String That You CAN Save and Later RESET.
PivotView.TotalorIntation
Uses Property to Make The Pivottable Control Display The Total Captions as Row Headings INSTEAD OF Column Headings.
Pivotgroupaxis.displayemptymembers
Uses Property to Force The Pivottable Control To Display Rows or Column That Are Completely Empty.
Table 4-3. Customizing and formatting the view.
Property
Description
Pivottable.autofituse this property to turn off the autofit behavior, especially for a form-based environment such as visual basic.
PivotView.Titlebar
Use this property to adjut the title bar's capension 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 number 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
............... ..
Pivottable.memberexpand
Uses Property to Make The Pivottable Control Automatically Expand All Fields and Members by Fields and Members.
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 Click 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 HAVEETHER Elements on Your Page OR FORM THAT SHANGE WHEN New VALUES ARE SELECTED.
PivottableChange
Fired for Various Reasons WHEN USING A Tabular Data Source. The Reason Parameter Tells You What Happend, 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 itsons.
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.