Excel.BindingDataChangedEventArgs interface
提供有关引发数据更改事件的绑定的信息。
注解
使用方
示例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/data-changed.yaml
async function registerDataChangedHandler() {
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Sample");
const salesTable = sheet.tables.getItem("SalesTable");
const salesByQuarterBinding = context.workbook.bindings.add(salesTable.getRange(), "Table", "SalesByQuarter");
salesByQuarterBinding.onDataChanged.add(onSalesDataChanged);
console.log("The data changed handler is registered.");
await context.sync();
});
}
async function onSalesDataChanged(eventArgs: Excel.BindingDataChangedEventArgs) {
await Excel.run(async (context) => {
console.log("Data was changed with binding " + eventArgs.binding.id);
// Get the name of the table that's changed.
const table: Excel.Table = context.workbook.bindings.getItem(eventArgs.binding.id).getTable();
table.load("name");
await context.sync();
console.log("Name of the changed table: " + table.name);
});
}
属性
| binding | 获取一个临时 |
属性详细信息
binding
获取一个临时 Binding 对象,其中包含引发事件的 Binding 对象的 ID。 使用该 ID 获取 BindingCollection.getItem(id) 绑定。
binding: Excel.Binding;