Cell.Filter
Cell.Filter is an object type of the Spreadsheet module (Office.cell(iframe)). 6 methods.
Spreadsheet · 6 object types · 156 methods · namespace Cell. This reference is generated from the API document artifact (sdk-api-doc.html) produced with the SDK build. Descriptions are the editor's API comments as published. Pin the SDK and Office versions together and regenerate when either changes.
Remarks
- Module: Spreadsheet ·
Office.cell(iframe)· namespaceCell - Obtained from:
Worksheet.getFilter(),Table.getFilter() - Every method returns a
Promise; signatures use TypeScript notation.
Methods
| Method | Description |
|---|---|
applyFilter(colId, criteria) | Applies a filter criteria to the given column. |
clearFilter(colId) | Clears filter criteria. |
create(range) | Creates an auto filter. |
getInfo() | Returns the filter area, the criteria per column, the number of rows hidden by the filter, and the sort state. |
remove() | Removes the auto filter. |
sort(colId, order) | Sorts the filter area by the given column and leaves the sort state on the filter. |
Method details
applyFilter(colId, criteria)
Applies a filter criteria to the given column. A null criteria clears that column's criteria. Giving a column whose header cell is merged applies it to the first column of the merged area. A sheet filter has to be created with create() first, but for a table, applying criteria without a filter creates one.
applyFilter(colId: number, criteria: Record<string, unknown> | null): Promise<void>;
Parameters
| Name | Type | Description |
|---|---|---|
colId | number | target column; a 0-based offset counted from the first column of the filter area (0 = the first column), the same coordinate system as columns[].colId in getInfo() |
criteria | Record<string, unknown> | null | criteria to apply; depending on filterType it uses one of the value-list, custom, top/bottom, or dynamic filter schemas, and the type and operator vocabularies come from the FilterType, FilterOperator, and FilterDynamicType constants. null clears the criteria |
Returns
Promise<void>
clearFilter(colId)
Clears filter criteria. With colId it clears that column only; omitting it clears every column that carries criteria. The filter buttons stay. It changes nothing when there is no criteria to clear or the table has no filter yet.
clearFilter(colId?: number): Promise<void>;
Parameters
| Name | Type | Description |
|---|---|---|
colId (optional) | number | column to clear; a 0-based offset counted from the first column of the filter area (0 = the first column). Omitting it clears every column |
Returns
Promise<void>
create(range)
Creates an auto filter. A sheet filter is created on the area given by range; omitting range expands to the data area around the current selection. A table filter ignores range and is created on the table area without the total row. It cannot be created when the target already has a filter, or when range is omitted and the selection is a single empty cell.
create(range?: string | RangeCoords): Promise<void>;
Parameters
| Name | Type | Description |
|---|---|---|
range (optional) | string | RangeCoords | area to create the filter on; an A1-notation string also works ("A1:B2", or "E10" for a single cell) |
Returns
Promise<void>
getInfo()
Returns the filter area, the criteria per column, the number of rows hidden by the filter, and the sort state. When no filter exists yet it carries only enabled as false and leaves the other fields out.
getInfo(): Promise<FilterInfo>;
Returns
Promise<FilterInfo>
remove()
Removes the auto filter. The filter area and the column criteria go with it.
remove(): Promise<void>;
Returns
Promise<void>
sort(colId, order)
Sorts the filter area by the given column and leaves the sort state on the filter. Giving a column whose header cell is merged sorts by the first column of the merged area. A table creates the filter along with the sort when there is none, but a sheet does not create one automatically, so create() has to run first.
sort(colId: number, order: SortOrder): Promise<Filter>;
Parameters
| Name | Type | Description |
|---|---|---|
colId | number | column to sort by; a 0-based offset counted from the first column of the filter area (0 = the first column), the same coordinate system as sort.colId in getInfo() |
order | SortOrder | sort direction; it accepts only the ascending and descending values of SortOrder |
Returns
Promise<Filter> - returns this handle as is, so that calls can be chained