Excel.PivotField class
Represents the Excel PivotField.
- Extends
Remarks
Properties
context | The request context associated with the object. This connects the add-in's process to the Office host application's process. |
id | ID of the PivotField. |
items | Returns the PivotItems associated with the PivotField. |
name | Name of the PivotField. |
show |
Determines whether to show all items of the PivotField. |
subtotals | Subtotals of the PivotField. |
Methods
load(options) | Queues up a command to load the specified properties of the object. You must call |
load(property |
Queues up a command to load the specified properties of the object. You must call |
load(property |
Queues up a command to load the specified properties of the object. You must call |
set(properties, options) | Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. |
set(properties) | Sets multiple properties on the object at the same time, based on an existing loaded object. |
sort |
Sorts the PivotField. If a DataPivotHierarchy is specified, then sort will be applied based on it, if not sort will be based on the PivotField itself. |
sort |
Sorts the PivotField by specified values in a given scope. The scope defines which specific values will be used to sort when there are multiple values from the same DataPivotHierarchy. |
sort |
Sorts the PivotField by specified values in a given scope. The scope defines which specific values will be used to sort when there are multiple values from the same DataPivotHierarchy. |
toJSON() | Overrides the JavaScript |
Property Details
context
The request context associated with the object. This connects the add-in's process to the Office host application's process.
context: RequestContext;
Property Value
id
items
Returns the PivotItems associated with the PivotField.
readonly items: Excel.PivotItemCollection;
Property Value
Remarks
name
showAllItems
Determines whether to show all items of the PivotField.
showAllItems: boolean;
Property Value
boolean
Remarks
subtotals
Subtotals of the PivotField.
subtotals: Excel.Subtotals;
Property Value
Remarks
Method Details
load(options)
Queues up a command to load the specified properties of the object. You must call context.sync()
before reading the properties.
load(options?: Excel.Interfaces.PivotFieldLoadOptions): Excel.PivotField;
Parameters
Provides options for which properties of the object to load.
Returns
load(propertyNames)
Queues up a command to load the specified properties of the object. You must call context.sync()
before reading the properties.
load(propertyNames?: string | string[]): Excel.PivotField;
Parameters
- propertyNames
-
string | string[]
A comma-delimited string or an array of strings that specify the properties to load.
Returns
load(propertyNamesAndPaths)
Queues up a command to load the specified properties of the object. You must call context.sync()
before reading the properties.
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Excel.PivotField;
Parameters
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select
is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand
is a comma-delimited string that specifies the navigation properties to load.
Returns
set(properties, options)
Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.
set(properties: Interfaces.PivotFieldUpdateData, options?: OfficeExtension.UpdateOptions): void;
Parameters
- properties
- Excel.Interfaces.PivotFieldUpdateData
A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called.
- options
- OfficeExtension.UpdateOptions
Provides an option to suppress errors if the properties object tries to set any read-only properties.
Returns
void
set(properties)
Sets multiple properties on the object at the same time, based on an existing loaded object.
set(properties: Excel.PivotField): void;
Parameters
- properties
- Excel.PivotField
Returns
void
sortByLabels(sortBy)
Sorts the PivotField. If a DataPivotHierarchy is specified, then sort will be applied based on it, if not sort will be based on the PivotField itself.
sortByLabels(sortBy: SortBy): void;
Parameters
- sortBy
- Excel.SortBy
Specifies if the sorting is done in ascending or descending order.
Returns
void
Remarks
sortByValues(sortBy, valuesHierarchy, pivotItemScope)
Sorts the PivotField by specified values in a given scope. The scope defines which specific values will be used to sort when there are multiple values from the same DataPivotHierarchy.
sortByValues(sortBy: Excel.SortBy, valuesHierarchy: Excel.DataPivotHierarchy, pivotItemScope?: Array<PivotItem | string>): void;
Parameters
- sortBy
- Excel.SortBy
Specifies if the sorting is done in ascending or descending order.
- valuesHierarchy
- Excel.DataPivotHierarchy
Specifies the values hierarchy on the data axis to be used for sorting.
- pivotItemScope
-
Array<Excel.PivotItem | string>
The items that should be used for the scope of the sorting. These will be the items that make up the row or column that you want to sort on. If a string is used instead of a PivotItem, the string represents the ID of the PivotItem. If there are no items other than data hierarchy on the axis you want to sort on, this can be empty.
Returns
void
Remarks
sortByValues(sortByString, valuesHierarchy, pivotItemScope)
Sorts the PivotField by specified values in a given scope. The scope defines which specific values will be used to sort when there are multiple values from the same DataPivotHierarchy.
sortByValues(sortByString: "Ascending" | "Descending", valuesHierarchy: Excel.DataPivotHierarchy, pivotItemScope?: Array<PivotItem | string>): void;
Parameters
- sortByString
-
"Ascending" | "Descending"
Specifies if the sorting is done in ascending or descending order.
- valuesHierarchy
- Excel.DataPivotHierarchy
Specifies the values hierarchy on the data axis to be used for sorting.
- pivotItemScope
-
Array<Excel.PivotItem | string>
The items that should be used for the scope of the sorting. These will be the items that make up the row or column that you want to sort on. If a string is used instead of a PivotItem, the string represents the ID of the PivotItem. If there are no items other than data hierarchy on the axis you want to sort on, this can be empty.
Returns
void
Remarks
toJSON()
Overrides the JavaScript toJSON()
method in order to provide more useful output when an API object is passed to JSON.stringify()
. (JSON.stringify
, in turn, calls the toJSON
method of the object that is passed to it.) Whereas the original Excel.PivotField
object is an API object, the toJSON
method returns a plain JavaScript object (typed as Excel.Interfaces.PivotFieldData
) that contains shallow copies of any loaded child properties from the original object.
toJSON(): Excel.Interfaces.PivotFieldData;
Returns
Office Add-ins