1. Trang chủ >
  2. Công Nghệ Thông Tin >
  3. Quản trị mạng >

Figure 20-21. Illustrating a calculated field

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5.72 MB, 490 trang )


The ErrorString property can be used to set the string that is displayed in cells that contain errors

when DisplayErrorString is True. (The default value is an empty string.)

20.5.5.4 Null-related properties

When the DisplayNullString property is True, the PivotTable displays a custom string in cells

that contain null values. (The default value is True.)

The NullString property can be used to set the custom string for such cells. (The default value is

an empty string.)

20.5.5.5 EnableDrillDown property

One of the features of a PivotTable is the DrillDown feature. To illustrate, if we double-click on a

data cell, such as cell D5 in the pivot table of Figure 20-10, Excel will create a new worksheet, as

shown in Figure 20-22. This worksheet shows the original source rows that contribute to the value

in the double-clicked cell D5. (Note that the rows are complete, although the Sales column does

not contribute to cell D5.)

Figure 20-22. Illustrating DrillDown



By now you have probably guessed that the read-write Boolean property EnableDrillDown is used

to enable or to disable this feature for the pivot table.

20.5.5.6 Formatting properties and methods

The read-write HasAutoFormat property is True (its default value) if the PivotTable is

automatically formatted when it is refreshed or when some of its fields are moved.

The labels for the rows, columns, subtotals, and totals in Figure 20-6 are not merged with adjacent

blank cells. (The borders are adjusted so it may appear so, however.) To merge the labels with

adjacent blank cells, we can set the MergeLabels property to True.

The read-write PreserveFormatting property is True (its default value) if PivotTable formatting is

preserved when the PivotTable is refreshed or recalculated by operations such as pivoting, sorting,

or changing page-field items.

The TableStyle property returns or sets the style name (as a string) used in the PivotTable body.

The default value is a null string, so no style is applied.

20.5.5.7 Refreshing a pivot table



315



When the ManualUpdate property is True, the PivotTable is recalculated only at the user's

request. The default value is False.

The RefreshTable method refreshes the PivotTable from the original source data. The method

returns True if it is successful.

The RefreshDate property returns the date on which the PivotTable or pivot cache was last

refreshed. It is read-only.

The RefreshName property returns the user name of the person who last refreshed the PivotTable

data or pivot cache.

20.5.5.8 PageField-related properties

As discussed earlier in the chapter, the PageFieldOrder property returns or sets the order in which

page fields are added to the PivotTable layout. It can be one of the following XlOrder constants:

xlDownThenOver or xlOverThenDown. The default constant is xlDownThenOver.

Recall also that the PageFieldWrapCount property returns or sets the number of PivotTable page

fields in each column or row.

The PageFieldStyle property returns or sets the style used in the page field area.

20.5.5.9 Name property

This property returns or sets the name of the pivot table as a string.

20.5.5.10 SaveData property (R/W Boolean)

When this property is True, its default value, data for the PivotTable is saved with the workbook.

If it is False, only the PivotTable definition is saved.

20.5.5.11 ShowPages method

This method creates a new PivotTable for each item in the specified page field. Each new

PivotTable is created on a new worksheet. The syntax is:



PivotTableObject.ShowPages(PageField)

For instance, if we apply this method to the pivot table in Figure 20-10 with the code:

ActiveSheet.PivotTables("Sales&Trans").ShowPages "Year"



we will get two new worksheets. One worksheet, named 1997, will contain the original pivot table,

but with the Year page field set to 1997. The other worksheet will contain the same pivot table

with the Year field set to 1998. (We can still change the Year field on any of the pivot tables. In

other words, each pivot table contains the data for all of the Year field values.)

20.5.5.12 SourceData property

This read-only property returns the data source for the PivotTable. For instance, when that source

is a single Excel worksheet, the SourceData method returns a string describing the source range.

The code:



316



debug.print ActiveSheet.PivotTables("Sales&Trans").SourceData



returns the string:

'Company Both'!R1C1:R145C7



20.6 Children of the PivotTable Object

The children of the PivotTable object are shown in Figure 20-23.



TE



AM

FL

Y



Figure 20-23. Children of the PivotTable object



20.7 The PivotField Object

The properties and methods of the PivotField object are shown in Table 20-3.



_Default



Table 20-3. Members of the PivotField Object

CurrentPageName

LayoutPageBreak



317 ®

Team-Fly



AddPageItem

Application

AutoShow

AutoShowCount

AutoShowField

AutoShowRange

AutoShowType

AutoSort

AutoSortField

AutoSortOrder

BaseField

BaseItem

CalculatedItems

Calculation

Caption

ChildField

ChildItems

Creator

CubeField

CurrentPage

CurrentPageList



DatabaseSort

DataRange

DataType

Delete

DragToColumn

DragToData

DragToHide

DragToPage

DragToRow

DrilledDown

EnableItemSelection

Formula

Function

GroupLevel

HiddenItems

HiddenItemsList

IsCalculated

IsMemberProperty

LabelRange

LayoutBlankLine

LayoutForm



LayoutSubtotalLocation

MemoryUsed

Name

NumberFormat

Orientation

Parent

ParentField

ParentItems

PivotItems

Position

PropertyOrder

PropertyParentField

ServerBased

ShowAllItems

SourceName

StandardFormula

SubtotalName

Subtotals

TotalLevels

Value

VisibleItems



Let us take a look at some of these members.



20.7.1 AutoShow-Related Members

The AutoShow method is used to restrict the display of pivot items for a given pivot field. The

syntax is:

PivotFieldObject.AutoShow(Type, Range, Count, Field)



All parameters are required for this method.

The Type parameter has two possible values: xlAutomatic activates the remaining parameters

and, thereby, causes the restrictions to take effect, and xlManual disables the remaining

parameters and causes Excel to remove any restrictions caused by a previous call to this method

with Type equal to xlAutomatic.

The other parameters can be described by the following sentence: restrict pivot items to the top

(Range =xlTop) or bottom (Range =xlBottom) Count pivot items based on the value in

pivot field Field.

Thus, for instance, referring to Figure 20-10, the code:

ActiveSheet.PivotTables("Sales&Trans"). _

PivotFields("Store Type").AutoShow _

xlAutomatic, xlTop, 1, "Sale"



shows the top (Range =xlTop and Count=1) Store Type based on the value of Sale. The result

is shown in Figure 20-24.



318



Xem Thêm
Tải bản đầy đủ (.pdf) (490 trang)

×