Excel.TableSort class
Manages sorting operations on Table
objects.
- 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. |
fields | Specifies the current conditions used to last sort the table. |
match |
Specifies if the casing impacts the last sort of the table. |
method | Represents the Chinese character ordering method last used to sort the table. |
Methods
apply(fields, match |
Perform a sort operation. |
apply(fields, match |
Perform a sort operation. |
clear() | Clears the sorting that is currently on the table. While this doesn't modify the table's ordering, it clears the state of the header buttons. |
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 |
reapply() | Reapplies the current sorting parameters to the table. |
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
fields
Specifies the current conditions used to last sort the table.
readonly fields: Excel.SortField[];
Property Value
Remarks
matchCase
Specifies if the casing impacts the last sort of the table.
readonly matchCase: boolean;
Property Value
boolean
Remarks
method
Represents the Chinese character ordering method last used to sort the table.
readonly method: Excel.SortMethod | "PinYin" | "StrokeCount";
Property Value
Excel.SortMethod | "PinYin" | "StrokeCount"
Remarks
Method Details
apply(fields, matchCase, method)
Perform a sort operation.
apply(fields: Excel.SortField[], matchCase?: boolean, method?: Excel.SortMethod): void;
Parameters
- fields
The list of conditions to sort on.
- matchCase
-
boolean
Optional. Whether to have the casing impact string ordering.
- method
- Excel.SortMethod
Optional. The ordering method used for Chinese characters.
Returns
void
Remarks
Examples
await Excel.run(async (context) => {
const tableName = 'Table1';
const table = context.workbook.tables.getItem(tableName);
table.sort.apply([
{
key: 2,
ascending: true
},
], true);
await context.sync();
});
apply(fields, matchCase, methodString)
Perform a sort operation.
apply(fields: Excel.SortField[], matchCase?: boolean, methodString?: "PinYin" | "StrokeCount"): void;
Parameters
- fields
The list of conditions to sort on.
- matchCase
-
boolean
Optional. Whether to have the casing impact string ordering.
- methodString
-
"PinYin" | "StrokeCount"
Optional. The ordering method used for Chinese characters.
Returns
void
Remarks
clear()
Clears the sorting that is currently on the table. While this doesn't modify the table's ordering, it clears the state of the header buttons.
clear(): void;
Returns
void
Remarks
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.TableSortLoadOptions): Excel.TableSort;
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.TableSort;
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.TableSort;
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
reapply()
Reapplies the current sorting parameters to the table.
reapply(): void;
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.TableSort
object is an API object, the toJSON
method returns a plain JavaScript object (typed as Excel.Interfaces.TableSortData
) that contains shallow copies of any loaded child properties from the original object.
toJSON(): Excel.Interfaces.TableSortData;
Returns
Office Add-ins