...
Step 4. Add PivotTableFields
Next, add PivotTable fields to the PivotTable.
In Excel, there are four types of PivotTable fields: data (or value) fields, column labels, row labels, and page fields (or report filters), which are generated from source fields.
There are four types of PivotTableField
: DataFields
, RowLabels
, ColumnLabels
, and PageFields
(also called report filters). The PivotTableField
properties are available for all four types of PivotTableField
, however some properties will not have an affect in the output file, depending on the type of field PivotTableFields
are created from read-only SourceFields
, which are generated based on the PivotTable
data source.
Note |
---|
A source field |
Get a handle on the SourceFields
to use for building PivotTableFields
later.
Code Block |
---|
SourceField prodSubCategory = pivot.SourceFields[0], prodName = pivot.SourceFields[1],
sales = pivot.SourceFields[2], dateStart = pivot.SourceFields[3],
dateEnd = pivot.SourceFields[4], prodStdCost = pivot.SourceFields[5],
listPrice = pivot.SourceFields[6], discount = pivot.SourceFields[7],
unitDiscountPrice = pivot.SourceFields[8];
|
PageFields
To add a PageField
, call CreateField
on the PivotTable.PageFields
collection. You will need to specify the SourceField
that will be used to create the PageField
.
...