Excel.FilterCriteria interface
Represents the filtering criteria applied to a column.
Remarks
Properties
color | The HTML color string used to filter cells. Used with |
criterion1 | The first criterion used to filter data. Used as an operator in the case of Used as a number in the case of top/bottom items/percents (e.g., "5" for the top 5 items if |
criterion2 | The second criterion used to filter data. Only used as an operator in the case of |
dynamic |
The dynamic criteria from the |
filter |
The property used by the filter to determine whether the values should stay visible. |
icon | The icon used to filter cells. Used with |
operator | The operator used to combine criterion 1 and 2 when using |
sub |
The property used by the filter to do a rich filter on rich values. |
values | The set of values to be used as part of |
Property Details
color
The HTML color string used to filter cells. Used with cellColor
and fontColor
filtering.
color?: string;
Property Value
string
Remarks
criterion1
The first criterion used to filter data. Used as an operator in the case of custom
filtering. For example ">50" for numbers greater than 50, or "=*s" for values ending in "s".
Used as a number in the case of top/bottom items/percents (e.g., "5" for the top 5 items if filterOn
is set to topItems
).
criterion1?: string;
Property Value
string
Remarks
criterion2
The second criterion used to filter data. Only used as an operator in the case of custom
filtering.
criterion2?: string;
Property Value
string
Remarks
dynamicCriteria
The dynamic criteria from the Excel.DynamicFilterCriteria
set to apply on this column. Used with dynamic
filtering.
dynamicCriteria?: Excel.DynamicFilterCriteria | "Unknown" | "AboveAverage" | "AllDatesInPeriodApril" | "AllDatesInPeriodAugust" | "AllDatesInPeriodDecember" | "AllDatesInPeriodFebruray" | "AllDatesInPeriodJanuary" | "AllDatesInPeriodJuly" | "AllDatesInPeriodJune" | "AllDatesInPeriodMarch" | "AllDatesInPeriodMay" | "AllDatesInPeriodNovember" | "AllDatesInPeriodOctober" | "AllDatesInPeriodQuarter1" | "AllDatesInPeriodQuarter2" | "AllDatesInPeriodQuarter3" | "AllDatesInPeriodQuarter4" | "AllDatesInPeriodSeptember" | "BelowAverage" | "LastMonth" | "LastQuarter" | "LastWeek" | "LastYear" | "NextMonth" | "NextQuarter" | "NextWeek" | "NextYear" | "ThisMonth" | "ThisQuarter" | "ThisWeek" | "ThisYear" | "Today" | "Tomorrow" | "YearToDate" | "Yesterday";
Property Value
Excel.DynamicFilterCriteria | "Unknown" | "AboveAverage" | "AllDatesInPeriodApril" | "AllDatesInPeriodAugust" | "AllDatesInPeriodDecember" | "AllDatesInPeriodFebruray" | "AllDatesInPeriodJanuary" | "AllDatesInPeriodJuly" | "AllDatesInPeriodJune" | "AllDatesInPeriodMarch" | "AllDatesInPeriodMay" | "AllDatesInPeriodNovember" | "AllDatesInPeriodOctober" | "AllDatesInPeriodQuarter1" | "AllDatesInPeriodQuarter2" | "AllDatesInPeriodQuarter3" | "AllDatesInPeriodQuarter4" | "AllDatesInPeriodSeptember" | "BelowAverage" | "LastMonth" | "LastQuarter" | "LastWeek" | "LastYear" | "NextMonth" | "NextQuarter" | "NextWeek" | "NextYear" | "ThisMonth" | "ThisQuarter" | "ThisWeek" | "ThisYear" | "Today" | "Tomorrow" | "YearToDate" | "Yesterday"
Remarks
filterOn
The property used by the filter to determine whether the values should stay visible.
filterOn: Excel.FilterOn | "BottomItems" | "BottomPercent" | "CellColor" | "Dynamic" | "FontColor" | "Values" | "TopItems" | "TopPercent" | "Icon" | "Custom";
Property Value
Excel.FilterOn | "BottomItems" | "BottomPercent" | "CellColor" | "Dynamic" | "FontColor" | "Values" | "TopItems" | "TopPercent" | "Icon" | "Custom"
Remarks
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-auto-filter.yaml
// This function adds a percentage AutoFilter to the active worksheet
// and applies the filter to a column of the used range.
await Excel.run(async (context) => {
// Retrieve the active worksheet and the used range on that worksheet.
const sheet = context.workbook.worksheets.getActiveWorksheet();
const farmData = sheet.getUsedRange();
// Add a filter that will only show the rows with the top 50% of values in column 3.
sheet.autoFilter.apply(farmData, 3, {
criterion1: "50",
filterOn: Excel.FilterOn.topPercent
});
await context.sync();
});
icon
The icon used to filter cells. Used with icon
filtering.
icon?: Excel.Icon;
Property Value
Remarks
operator
The operator used to combine criterion 1 and 2 when using custom
filtering.
operator?: Excel.FilterOperator | "And" | "Or";
Property Value
Excel.FilterOperator | "And" | "Or"
Remarks
subField
The property used by the filter to do a rich filter on rich values.
subField?: string;
Property Value
string
Remarks
values
The set of values to be used as part of values
filtering.
values?: Array<string | FilterDatetime>;
Property Value
Array<string | Excel.FilterDatetime>
Remarks
Office Add-ins