Excel.WorksheetMovedEventArgs interface
在工作簿中移动工作表时发出通知。
如果通过 Excel UI 将工作表从工作簿中的一个位置移动到另一个位置,则此 API 将触发一个事件。 请注意,如果由于移动不同的工作表而导致工作表的位置发生更改,则两个位置更改都不会触发此事件。 此事件仅触发主要工作表移动,而不触发由于该主要移动而发生的任何工作表位置更改。
注解
使用方
示例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-workbook-and-worksheet-collection.yaml
async function onWorksheetMoved(event) {
await Excel.run(async (context) => {
console.log("Handler for worksheet onMoved event has been triggered.");
console.log(` Worksheet ID: ${event.worksheetId}`);
console.log(` Position before move: ${event.positionBefore}`);
console.log(` Position after move: ${event.positionAfter}`);
console.log(` Event source: ${event.source}`);
});
}
属性
| position |
移动后获取工作表的新位置。 |
| position |
获取移动之前工作表的上一个位置。 |
| source | 事件的源。 它可以是本地的,也可以通过共同创作) 远程 (。 |
| type | 获取事件的类型。 |
| worksheet |
获取已移动的工作表的 ID。 |
属性详细信息
positionAfter
positionBefore
source
事件的源。 它可以是本地的,也可以通过共同创作) 远程 (。
source: Excel.EventSource | "Local" | "Remote";
属性值
Excel.EventSource | "Local" | "Remote"