Excel.TableSort class

管理对 Table 对象的排序操作。

Extends

注解

[ API 集:ExcelApi 1.2 ]

属性

context

与 对象关联的请求上下文。 这会将加载项的进程连接到 Office 主机应用程序的进程。

fields

指定用于上次对表进行排序的当前条件。

matchCase

指定大小写是否影响表的最后一种类型。

method

表示上次用于对表进行排序的中文字符排序方法。

方法

apply(fields, matchCase, method)

执行排序操作。

apply(fields, matchCase, methodString)

执行排序操作。

clear()

清除表上的当前排序。 尽管这不能修改表的排序,但它会清除标题按钮的状态。

load(options)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

load(propertyNames)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

load(propertyNamesAndPaths)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

reapply()

对 table 重新应用当前的排序参数。

toJSON()

重写 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 JSON.stringify (,反过来又调用toJSON传递给它的 对象的 方法。) 而原始 Excel.TableSort 对象是 API 对象,toJSON该方法返回一个纯 JavaScript 对象, (类型为 Excel.Interfaces.TableSortData) ,其中包含从原始对象加载的任何子属性的浅表副本。

属性详细信息

context

与 对象关联的请求上下文。 这会将加载项的进程连接到 Office 主机应用程序的进程。

context: RequestContext;

属性值

fields

指定用于上次对表进行排序的当前条件。

readonly fields: Excel.SortField[];

属性值

注解

[ API 集:ExcelApi 1.2 ]

matchCase

指定大小写是否影响表的最后一种类型。

readonly matchCase: boolean;

属性值

boolean

注解

[ API 集:ExcelApi 1.2 ]

method

表示上次用于对表进行排序的中文字符排序方法。

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

属性值

Excel.SortMethod | "PinYin" | "StrokeCount"

注解

[ API 集:ExcelApi 1.2 ]

方法详细信息

apply(fields, matchCase, method)

执行排序操作。

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

参数

fields

Excel.SortField[]

要用作排序依据的条件列表。

matchCase

boolean

可选。 是否让大小写对字符串排序产生影响。

method
Excel.SortMethod

可选。 用于中文字符的排序方法。

返回

void

注解

[ API 集:ExcelApi 1.2 ]

示例

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)

执行排序操作。

apply(fields: Excel.SortField[], matchCase?: boolean, methodString?: "PinYin" | "StrokeCount"): void;

参数

fields

Excel.SortField[]

要用作排序依据的条件列表。

matchCase

boolean

可选。 是否让大小写对字符串排序产生影响。

methodString

"PinYin" | "StrokeCount"

可选。 用于中文字符的排序方法。

返回

void

注解

[ API 集:ExcelApi 1.2 ]

clear()

清除表上的当前排序。 尽管这不能修改表的排序,但它会清除标题按钮的状态。

clear(): void;

返回

void

注解

[ API 集:ExcelApi 1.2 ]

load(options)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

load(options?: Excel.Interfaces.TableSortLoadOptions): Excel.TableSort;

参数

options
Excel.Interfaces.TableSortLoadOptions

提供要加载对象的属性的选项。

返回

load(propertyNames)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

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

参数

propertyNames

string | string[]

逗号分隔的字符串或指定要加载的属性的字符串数组。

返回

load(propertyNamesAndPaths)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Excel.TableSort;

参数

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select 是一个逗号分隔的字符串,指定要加载的属性,是 propertyNamesAndPaths.expand 一个逗号分隔的字符串,指定要加载的导航属性。

返回

reapply()

对 table 重新应用当前的排序参数。

reapply(): void;

返回

void

注解

[ API 集:ExcelApi 1.2 ]

toJSON()

重写 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 JSON.stringify (,反过来又调用toJSON传递给它的 对象的 方法。) 而原始 Excel.TableSort 对象是 API 对象,toJSON该方法返回一个纯 JavaScript 对象, (类型为 Excel.Interfaces.TableSortData) ,其中包含从原始对象加载的任何子属性的浅表副本。

toJSON(): Excel.Interfaces.TableSortData;

返回