Excel.LabelFilterCondition enum
Enum representing all accepted conditions by which a label filter can be applied. Used to configure the type of PivotFilter that is applied to the field. PivotFilter.criteria.exclusive
can be set to true
to invert many of these conditions.
Remarks
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotfilters.yaml
await Excel.run(async (context) => {
// Add a PivotFilter to filter based on the strings of item labels.
// Get the PivotTable.
const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales");
// Get the "Type" field.
const field = pivotTable.hierarchies.getItem("Type").fields.getItem("Type");
// Filter out any types that start with "L" ("Lemons" and "Limes" in this case).
const filter: Excel.PivotLabelFilter = {
condition: Excel.LabelFilterCondition.beginsWith,
substring: "L",
exclusive: true
};
// Apply the label filter to the field.
field.applyFilter({ labelFilter: filter });
await context.sync();
});
Fields
beginsWith = "BeginsWith" | Label begins with substring criterion. Required Criteria: { |
between = "Between" | Between Required Criteria: { |
contains = "Contains" | Label contains substring criterion. Required Criteria: { |
endsWith = "EndsWith" | Label ends with substring criterion. Required Criteria: { |
equals = "Equals" | Equals comparator criterion. Required Criteria: { |
greaterThan = "GreaterThan" | Greater than comparator criterion. Required Criteria: { |
greaterThanOrEqualTo = "GreaterThanOrEqualTo" | Greater than or equal to comparator criterion. Required Criteria: { |
lessThan = "LessThan" | Less than comparator criterion. Required Criteria: { |
lessThanOrEqualTo = "LessThanOrEqualTo" | Less than or equal to comparator criterion. Required Criteria: { |
unknown = "Unknown" |
|
Office Add-ins