Excel.Table class

表示一个 Excel 表。Represents an Excel table.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

Extends

属性

autoFilter

表示表格的 AutoFilter 对象。Represents the AutoFilter object of the table. 只读。Read-Only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

columns

表示表中所有列的集合。Represents a collection of all the columns in the table. 只读。Read-only.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

context

与该对象关联的请求上下文。The request context associated with the object. 这会将加载项的进程连接到 Office 主机应用程序的进程。This connects the add-in's process to the Office host application's process.

highlightFirstColumn

指明第一列是否包含特殊格式。Indicates whether the first column contains special formatting.

[API 集: ExcelApi 1.3][ API set: ExcelApi 1.3 ]

highlightLastColumn

指明最后一列是否包含特殊格式。Indicates whether the last column contains special formatting.

[API 集: ExcelApi 1.3][ API set: ExcelApi 1.3 ]

id

返回用于唯一标识指定工作簿中表的值。即使表被重命名,标识符的值仍然相同。只读。Returns a value that uniquely identifies the table in a given workbook. The value of the identifier remains the same even when the table is renamed. Read-only.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

legacyId

返回一个数字 id。Returns a numeric id.

[API 集: ExcelApi 1.8][ API set: ExcelApi 1.8 ]

name

表的名称。Name of the table.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

rows

表示表中所有行的集合。Represents a collection of all the rows in the table. 只读。Read-only.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

showBandedColumns

指明列是否采用镶边格式来以不同的方式突出显示奇数列与偶数列,让表更易于阅读。Indicates whether the columns show banded formatting in which odd columns are highlighted differently from even ones to make reading the table easier.

[API 集: ExcelApi 1.3][ API set: ExcelApi 1.3 ]

showBandedRows

指明行是否采用镶边格式来以不同的方式突出显示奇数行与偶数行,让表更易于阅读。Indicates whether the rows show banded formatting in which odd rows are highlighted differently from even ones to make reading the table easier.

[API 集: ExcelApi 1.3][ API set: ExcelApi 1.3 ]

showFilterButton

指明是否在每个列标题的顶部显示筛选器按钮。仅当 table 中包含标题行时,才允许设定此设置。Indicates whether the filter buttons are visible at the top of each column header. Setting this is only allowed if the table contains a header row.

[API 集: ExcelApi 1.3][ API set: ExcelApi 1.3 ]

showHeaders

指示标头行是否可见。Indicates whether the header row is visible or not. 该值可以设置为显示或删除标头行。This value can be set to show or remove the header row.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

showTotals

指示总计行是否可见。Indicates whether the total row is visible or not. 该值可以设置为显示或删除总计行。This value can be set to show or remove the total row.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

sort

表示表的排序。Represents the sorting for the table. 只读。Read-only.

[API 集: ExcelApi 1.2][ API set: ExcelApi 1.2 ]

style

表示表格样式的常量值。Constant value that represents the Table style. 可能的值为: "TableStyleLight1" 到 "TableStyleLight21"、"TableStyleMedium1" 通过 "TableStyleMedium28"、"TableStyleStyleDark1" 到 "TableStyleStyleDark11"。Possible values are: "TableStyleLight1" through "TableStyleLight21", "TableStyleMedium1" through "TableStyleMedium28", "TableStyleStyleDark1" through "TableStyleStyleDark11". 还可以指定工作簿中显示的用户定义的自定义样式。A custom user-defined style present in the workbook can also be specified.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

worksheet

包含当前表格的工作表。The worksheet containing the current table. 只读。Read-only.

[API 集: ExcelApi 1.2][ API set: ExcelApi 1.2 ]

方法

clearFilters()

清除当前表上应用的所有筛选器。Clears all the filters currently applied on the table.

[API 集: ExcelApi 1.2][ API set: ExcelApi 1.2 ]

clearStyle()

将表格更改为使用默认表格样式。Changes the table to use the default table style.

[API 集: EXCELAPI BETA (仅限预览)][ API set: ExcelApi BETA (PREVIEW ONLY) ]

convertToRange()

将表转换为普通单元格区域。Converts the table into a normal range of cells. 保留所有数据。All data is preserved.

[API 集: ExcelApi 1.2][ API set: ExcelApi 1.2 ]

delete()

删除表。Deletes the table.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

getDataBodyRange()

获取与表的数据体相关的 range 对象。Gets the range object associated with the data body of the table.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

getHeaderRowRange()

获取与表的标头行相关的 range 对象。Gets the range object associated with header row of the table.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

getRange()

获取与整个表相关的 range 对象。Gets the range object associated with the entire table.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

getTotalRowRange()

获取与表的总计行相关的 range 对象。Gets the range object associated with totals row of the table.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

load(option)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性之前,你必须调用“context.sync()”。You must call "context.sync()" before reading the properties.

load(propertyNames)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性context.sync()之前, 必须先调用。You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性context.sync()之前, 必须先调用。You must call context.sync() before reading the properties.

reapplyFilters()

重新应用当前在 table 上应用的所有 filter。Reapplies all the filters currently on the table.

[API 集: ExcelApi 1.2][ API set: ExcelApi 1.2 ]

set(properties, options)

同时设置一个对象的多个属性。Sets multiple properties of an object at the same time. 您可以传递具有相应属性的纯对象或相同类型的其他 API 对象。You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties)

基于现有加载的对象同时设置该对象的多个属性。Sets multiple properties on the object at the same time, based on an existing loaded object.

toJSON()

重写 JavaScript toJSON()方法, 以便在将 API 对象传递到时提供更有用的输出JSON.stringify()Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify反过来, 也会调用传递toJSON给它的对象的方法。尽管原始的 Excel 表对象是 API 对象, 但toJSON方法返回一个简单的 JavaScript 对象 (类型为Excel.Interfaces.TableData, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.Table object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.TableData), 其中包含原始对象中所有已加载的子属性的浅表副本。) that contains shallow copies of any loaded child properties from the original object.

事件

onChanged

当特定表上单元格的数据更改时发生。Occurs when data in cells changes on a specific table.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

onFiltered

在特定表格上应用筛选器时发生。Occurs when filter is applied on a specific table.

[API 集: EXCELAPI BETA (仅限预览)][ API set: ExcelApi BETA (PREVIEW ONLY) ]

onSelectionChanged

当特定表格上的所选内容更改时发生。Occurs when the selection changes on a specific table.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

属性详细信息

autoFilter

表示表格的 AutoFilter 对象。Represents the AutoFilter object of the table. 只读。Read-Only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly autoFilter: Excel.AutoFilter;

属性值

columns

表示表中所有列的集合。Represents a collection of all the columns in the table. 只读。Read-only.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

readonly columns: Excel.TableColumnCollection;

属性值

context

与该对象关联的请求上下文。The request context associated with the object. 这会将加载项的进程连接到 Office 主机应用程序的进程。This connects the add-in's process to the Office host application's process.

context: RequestContext;

属性值

RequestContext

highlightFirstColumn

指明第一列是否包含特殊格式。Indicates whether the first column contains special formatting.

[API 集: ExcelApi 1.3][ API set: ExcelApi 1.3 ]

highlightFirstColumn: boolean;

属性值

boolean

highlightLastColumn

指明最后一列是否包含特殊格式。Indicates whether the last column contains special formatting.

[API 集: ExcelApi 1.3][ API set: ExcelApi 1.3 ]

highlightLastColumn: boolean;

属性值

boolean

id

返回用于唯一标识指定工作簿中表的值。即使表被重命名,标识符的值仍然相同。只读。Returns a value that uniquely identifies the table in a given workbook. The value of the identifier remains the same even when the table is renamed. Read-only.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

readonly id: string;

属性值

string

legacyId

返回一个数字 id。Returns a numeric id.

[API 集: ExcelApi 1.8][ API set: ExcelApi 1.8 ]

readonly legacyId: string;

属性值

string

name

表的名称。Name of the table.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

name: string;

属性值

string

rows

表示表中所有行的集合。Represents a collection of all the rows in the table. 只读。Read-only.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

readonly rows: Excel.TableRowCollection;

属性值

showBandedColumns

指明列是否采用镶边格式来以不同的方式突出显示奇数列与偶数列,让表更易于阅读。Indicates whether the columns show banded formatting in which odd columns are highlighted differently from even ones to make reading the table easier.

[API 集: ExcelApi 1.3][ API set: ExcelApi 1.3 ]

showBandedColumns: boolean;

属性值

boolean

showBandedRows

指明行是否采用镶边格式来以不同的方式突出显示奇数行与偶数行,让表更易于阅读。Indicates whether the rows show banded formatting in which odd rows are highlighted differently from even ones to make reading the table easier.

[API 集: ExcelApi 1.3][ API set: ExcelApi 1.3 ]

showBandedRows: boolean;

属性值

boolean

showFilterButton

指明是否在每个列标题的顶部显示筛选器按钮。仅当 table 中包含标题行时,才允许设定此设置。Indicates whether the filter buttons are visible at the top of each column header. Setting this is only allowed if the table contains a header row.

[API 集: ExcelApi 1.3][ API set: ExcelApi 1.3 ]

showFilterButton: boolean;

属性值

boolean

showHeaders

指示标头行是否可见。Indicates whether the header row is visible or not. 该值可以设置为显示或删除标头行。This value can be set to show or remove the header row.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

showHeaders: boolean;

属性值

boolean

showTotals

指示总计行是否可见。Indicates whether the total row is visible or not. 该值可以设置为显示或删除总计行。This value can be set to show or remove the total row.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

showTotals: boolean;

属性值

boolean

sort

表示表的排序。Represents the sorting for the table. 只读。Read-only.

[API 集: ExcelApi 1.2][ API set: ExcelApi 1.2 ]

readonly sort: Excel.TableSort;

属性值

style

表示表格样式的常量值。Constant value that represents the Table style. 可能的值为: "TableStyleLight1" 到 "TableStyleLight21"、"TableStyleMedium1" 通过 "TableStyleMedium28"、"TableStyleStyleDark1" 到 "TableStyleStyleDark11"。Possible values are: "TableStyleLight1" through "TableStyleLight21", "TableStyleMedium1" through "TableStyleMedium28", "TableStyleStyleDark1" through "TableStyleStyleDark11". 还可以指定工作簿中显示的用户定义的自定义样式。A custom user-defined style present in the workbook can also be specified.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

style: string;

属性值

string

worksheet

包含当前表格的工作表。The worksheet containing the current table. 只读。Read-only.

[API 集: ExcelApi 1.2][ API set: ExcelApi 1.2 ]

readonly worksheet: Excel.Worksheet;

属性值

方法详细信息

clearFilters()

清除当前表上应用的所有筛选器。Clears all the filters currently applied on the table.

[API 集: ExcelApi 1.2][ API set: ExcelApi 1.2 ]

clearFilters(): void;

返回

void

clearStyle()

备注

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

将表格更改为使用默认表格样式。Changes the table to use the default table style.

[API 集: EXCELAPI BETA (仅限预览)][ API set: ExcelApi BETA (PREVIEW ONLY) ]

clearStyle(): void;

返回

void

convertToRange()

将表转换为普通单元格区域。Converts the table into a normal range of cells. 保留所有数据。All data is preserved.

[API 集: ExcelApi 1.2][ API set: ExcelApi 1.2 ]

convertToRange(): Excel.Range;

返回

示例Examples

Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var table = ctx.workbook.tables.getItem(tableName);
    table.convertToRange();
    return ctx.sync(); 
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

delete()

删除表。Deletes the table.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

delete(): void;

返回

void

示例Examples

Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var table = ctx.workbook.tables.getItem(tableName);
    table.delete();
    return ctx.sync(); 
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

getDataBodyRange()

获取与表的数据体相关的 range 对象。Gets the range object associated with the data body of the table.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

getDataBodyRange(): Excel.Range;

返回

示例Examples

Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var table = ctx.workbook.tables.getItem(tableName);
    var tableDataRange = table.getDataBodyRange();
    tableDataRange.load('address')
    return ctx.sync().then(function() {
            console.log(tableDataRange.address);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

getHeaderRowRange()

获取与表的标头行相关的 range 对象。Gets the range object associated with header row of the table.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

getHeaderRowRange(): Excel.Range;

返回

示例Examples

Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var table = ctx.workbook.tables.getItem(tableName);
    var tableHeaderRange = table.getHeaderRowRange();
    tableHeaderRange.load('address');
    return ctx.sync().then(function() {
        console.log(tableHeaderRange.address);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

getRange()

获取与整个表相关的 range 对象。Gets the range object associated with the entire table.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

getRange(): Excel.Range;

返回

示例Examples

Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var table = ctx.workbook.tables.getItem(tableName);
    var tableRange = table.getRange();
    tableRange.load('address');    
    return ctx.sync().then(function() {
            console.log(tableRange.address);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

getTotalRowRange()

获取与表的总计行相关的 range 对象。Gets the range object associated with totals row of the table.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

getTotalRowRange(): Excel.Range;

返回

示例Examples

Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var table = ctx.workbook.tables.getItem(tableName);
    var tableTotalsRange = table.getTotalRowRange();
    tableTotalsRange.load('address');    
    return ctx.sync().then(function() {
            console.log(tableTotalsRange.address);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

load(option)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性之前,你必须调用“context.sync()”。You must call "context.sync()" before reading the properties.

load(option?: Excel.Interfaces.TableLoadOptions): Excel.Table;

参数

返回

注解

除了此签名之外, 此方法还具有以下签名:In addition to this signature, this method has the following signatures:

load(option?: string | string[]): Excel.Table-Where 选项是一个逗号分隔的字符串或一个字符串数组, 用于指定要加载的属性。load(option?: string | string[]): Excel.Table - Where option is a comma-delimited string or an array of strings that specify the properties to load.

load(option?: { select?: string; expand?: string; }): Excel.Table-Where 选项。选择是一个用逗号分隔的字符串, 用于指定要加载的属性和选项。 expand 是一个用逗号分隔的字符串, 用于指定要加载的导航属性。load(option?: { select?: string; expand?: string; }): Excel.Table - 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.Table-仅适用于集合类型。load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.Table - Only available on collection types. 它类似于前面的签名。It is similar to the preceding signature. Top 指定结果中可包含的集合项的最大数量。Option.top specifies the maximum number of collection items that can be included in the result. 选项。 skip 指定要跳过且不包含在结果中的项目数。Option.skip specifies the number of items that are to be skipped and not included in the result. 如果指定了 top 选项, 则在跳过指定数目的项目后将启动结果集。If option.top is specified, the result set will start after skipping the specified number of items.

load(propertyNames)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性context.sync()之前, 必须先调用。You must call context.sync() before reading the properties.

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

参数

propertyNames
string | string[]

一个以逗号分隔的字符串或字符串数组, 用于指定要加载的属性。A comma-delimited string or an array of strings that specify the properties to load.

返回

示例Examples

// Get a table by name. 
Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var table = ctx.workbook.tables.getItem(tableName);
    table.load('index')
    return ctx.sync().then(function() {
            console.log(table.index);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});
// Get a table by index.
Excel.run(function (ctx) { 
    var index = 0;
    var table = ctx.workbook.tables.getItemAt(0);
    table.load('id')
    return ctx.sync().then(function() {
            console.log(table.id);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});
// Set table style. 
Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var table = ctx.workbook.tables.getItem(tableName);
    table.name = 'Table1-Renamed';
    table.showTotals = false;
    table.style = 'TableStyleMedium2';
    table.load('tableStyle');
    return ctx.sync().then(function() {
            console.log(table.style);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

load(propertyNamesAndPaths)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性context.sync()之前, 必须先调用。You must call context.sync() before reading the properties.

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

参数

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

其中, propertyNamesAndPaths 是用逗号分隔的字符串, 用于指定要加载的属性和 propertyNamesAndPaths。扩展是一个用逗号分隔的字符串, 用于指定要加载的导航属性。Where 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.

返回

reapplyFilters()

重新应用当前在 table 上应用的所有 filter。Reapplies all the filters currently on the table.

[API 集: ExcelApi 1.2][ API set: ExcelApi 1.2 ]

reapplyFilters(): void;

返回

void

set(properties, options)

同时设置一个对象的多个属性。Sets multiple properties of an object at the same time. 您可以传递具有相应属性的纯对象或相同类型的其他 API 对象。You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties: Interfaces.TableUpdateData, options?: OfficeExtension.UpdateOptions): void;

参数

properties
Interfaces.TableUpdateData

一个 JavaScript 对象, 其属性的结构 isomorphically 为在其上调用方法的对象的属性。A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called.

options
OfficeExtension.UpdateOptions

提供一个选项, 以在 properties 对象尝试设置任何只读属性时禁止显示错误。Provides an option to suppress errors if the properties object tries to set any read-only properties.

返回

void

注解

此方法具有以下附加签名:This method has the following additional signature:

set(properties: Excel.Table): void

set(properties)

基于现有加载的对象同时设置该对象的多个属性。Sets multiple properties on the object at the same time, based on an existing loaded object.

set(properties: Excel.Table): void;

参数

properties
Excel.Table

返回

void

toJSON()

重写 JavaScript toJSON()方法, 以便在将 API 对象传递到时提供更有用的输出JSON.stringify()Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify反过来, 也会调用传递toJSON给它的对象的方法。尽管原始的 Excel 表对象是 API 对象, 但toJSON方法返回一个简单的 JavaScript 对象 (类型为Excel.Interfaces.TableData, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.Table object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.TableData), 其中包含原始对象中所有已加载的子属性的浅表副本。) that contains shallow copies of any loaded child properties from the original object.

toJSON(): Excel.Interfaces.TableData;

返回

事件详细信息

onChanged

当特定表上单元格的数据更改时发生。Occurs when data in cells changes on a specific table.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

readonly onChanged: OfficeExtension.EventHandlers<Excel.TableChangedEventArgs>;

返回

OfficeExtension.EventHandlers<Excel.TableChangedEventArgs>

示例Examples

await Excel.run(async (context) => {
    let table = context.workbook.tables.getItemAt(0);
    table.onChanged.add(onChange);

    await context.sync();
    console.log("A handler has been registered for the onChanged event");
});

onFiltered

备注

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

在特定表格上应用筛选器时发生。Occurs when filter is applied on a specific table.

[API 集: EXCELAPI BETA (仅限预览)][ API set: ExcelApi BETA (PREVIEW ONLY) ]

readonly onFiltered: OfficeExtension.EventHandlers<Excel.TableFilteredEventArgs>;

返回

OfficeExtension.EventHandlers<Excel.TableFilteredEventArgs>

onSelectionChanged

当特定表格上的所选内容更改时发生。Occurs when the selection changes on a specific table.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

readonly onSelectionChanged: OfficeExtension.EventHandlers<Excel.TableSelectionChangedEventArgs>;

返回

OfficeExtension.EventHandlers<Excel.TableSelectionChangedEventArgs>

示例Examples

await Excel.run(async (context) => {
    let table = context.workbook.tables.getItemAt(0);
    table.onSelectionChanged.add(onSelectionChange);

    await context.sync();
    console.log("A handler has been registered for table onSelectionChanged event");
});