Excel.FilterCriteria interface
表示应用于列的筛选条件。
属性
| color | 用于筛选单元格的 HTML 颜色字符串。 与和筛选一起使用 |
| criterion1 | 第一个条件用于筛选数据。 在筛选的情况下 在顶部/底部项目/百分比 (的情况下用作数字,例如,如果设置为 |
| criterion2 | 第二个条件用于筛选数据。 仅在筛选时 |
| dynamic |
要应用于此列的 |
| filter |
筛选器使用的属性,用于确定是否应将值保持为可见时。 |
| icon | 用于筛选单元格的图标。 与筛选一起使用 |
| operator | 使用 |
| sub |
筛选器用于对丰富值进行丰富筛选的属性。 |
| values | 要用作筛选一部分的 |
属性详细信息
color
criterion1
第一个条件用于筛选数据。 在筛选的情况下 custom 用作运算符。 例如,>“50”表示大于 50 的数字,“=*s”表示以“s”结尾的值。
在顶部/底部项目/百分比 (的情况下用作数字,例如,如果设置为 topItems) ,则filterOn表示前 5 个项目为“5”。
criterion1?: string;
属性值
string
注解
criterion2
dynamicCriteria
要应用于此列的 Excel.DynamicFilterCriteria 集中的动态条件。 与筛选一起使用 dynamic 。
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";
属性值
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"
注解
filterOn
筛选器使用的属性,用于确定是否应将值保持为可见时。
filterOn: Excel.FilterOn | "BottomItems" | "BottomPercent" | "CellColor" | "Dynamic" | "FontColor" | "Values" | "TopItems" | "TopPercent" | "Icon" | "Custom";
属性值
Excel.FilterOn | "BottomItems" | "BottomPercent" | "CellColor" | "Dynamic" | "FontColor" | "Values" | "TopItems" | "TopPercent" | "Icon" | "Custom"
注解
示例
// 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
operator
使用 custom 筛选时用于组合条件 1 和 2 的运算符。
operator?: Excel.FilterOperator | "And" | "Or";
属性值
Excel.FilterOperator | "And" | "Or"
注解
subField
values
要用作筛选一部分的 values 值集。
values?: Array<string | FilterDatetime>;
属性值
Array<string | Excel.FilterDatetime>