Excel.TableSort class

Manages sorting operations on Table objects.

[ API set: ExcelApi 1.2 ]

Extends
OfficeExtension.ClientObject

Properties

fields

Represents the current conditions used to last sort the table. Read-only.

[ API set: ExcelApi 1.2 ]

matchCase

Represents whether the casing impacted the last sort of the table. Read-only.

[ API set: ExcelApi 1.2 ]

method

Represents Chinese character ordering method last used to sort the table. Read-only.

[ API set: ExcelApi 1.2 ]

Methods

apply(fields, matchCase, method)

Perform a sort operation.

[ API set: ExcelApi 1.2 ]

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.

[ API set: ExcelApi 1.2 ]

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

reapply()

Reapplies the current sorting parameters to the table.

[ API set: ExcelApi 1.2 ]

toJSON()

Property Details

fields

Represents the current conditions used to last sort the table. Read-only.

[ API set: ExcelApi 1.2 ]

readonly fields: Excel.SortField[];
Property Value
Excel.SortField[]

matchCase

Represents whether the casing impacted the last sort of the table. Read-only.

[ API set: ExcelApi 1.2 ]

readonly matchCase: boolean;
Property Value
boolean

method

Represents Chinese character ordering method last used to sort the table. Read-only.

[ API set: ExcelApi 1.2 ]

readonly method: Excel.SortMethod | "PinYin" | "StrokeCount";
Property Value
Excel.SortMethod | "PinYin" | "StrokeCount"

Method Details

apply(fields, matchCase, method)

Perform a sort operation.

[ API set: ExcelApi 1.2 ]

apply(fields: Excel.SortField[], matchCase?: boolean, method?: Excel.SortMethod): void;
Parameters
fields
Excel.SortField[]

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

Examples

Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var table = ctx.workbook.tables.getItem(tableName);
    table.sort.apply([ 
            {
                key: 2,
                ascending: true
            },
        ], true);
    return ctx.sync(); 
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

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.

[ API set: ExcelApi 1.2 ]

clear(): void;
Returns
void

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

load(option?: string | string[]): Excel.TableSort;
Parameters
option
string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns
Remarks

In addition to this signature, this method has the following signatures:

load(option?: { select?: string; expand?: string; }): Excel.TableSort - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load.

load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.TableSort - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items.

reapply()

Reapplies the current sorting parameters to the table.

[ API set: ExcelApi 1.2 ]

reapply(): void;
Returns
void

toJSON()

toJSON(): Excel.Interfaces.TableSortData;
Returns