Excel.WorksheetSelectionChangedEventArgs interface
Provides information about the worksheet that raised the selection changed event.
Remarks
Examples
async function registerEventHandlers() {
await Excel.run(async (context) => {
// Add a selection changed event handler for the worksheet.
let sheet = context.workbook.worksheets.getItem("Sample");
sheet.onSelectionChanged.add(onWorksheetSelectionChange);
// Add a selection changed event handler for the worksheet collection.
context.workbook.worksheets.onSelectionChanged.add(onWorksheetCollectionSelectionChange);
await context.sync();
});
}
async function onWorksheetSelectionChange(args: Excel.WorksheetSelectionChangedEventArgs) {
await Excel.run(async (context) => {
console.log(`Worksheet event: The address of new selection is: ${args.address}`);
});
}
async function onWorksheetCollectionSelectionChange(args: Excel.WorksheetSelectionChangedEventArgs) {
await Excel.run(async (context) => {
console.log(`WorksheetCollection event: The address of new selection is: ${args.address}`);
});
}
Properties
| address | Gets the range address that represents the selected area of a specific worksheet. |
| type | Gets the type of the event. See |
| worksheet |
Gets the ID of the worksheet in which the selection changed. |
Property Details
address
Gets the range address that represents the selected area of a specific worksheet.
address: string;
Property Value
string
Remarks
type
Gets the type of the event. See Excel.EventType for details.
type: "WorksheetSelectionChanged";
Property Value
"WorksheetSelectionChanged"
Remarks
worksheetId
Gets the ID of the worksheet in which the selection changed.
worksheetId: string;
Property Value
string