Forum Discussion
terryAnastassiadis
Mar 13, 2023Copper Contributor
Excel for Web, Office Scripts: TypeScript/ExelScript Event Listener Support
Hi All, I was taking a look at the ExcelScript API but unless I missed something I have the feeling that Event Listeners are not currently implemented in Office Scripts (TypeScript/ExcelScript) f...
- Mar 15, 2023I have exploded all api of excel.script and found NO anwser.
If you want to interactive function, script lab may useful.(https://learn.microsoft.com/en-us/office/dev/add-ins/tutorials/excel-tutorial?source=recommendations)
peiyezhu
Mar 15, 2023Bronze Contributor
I have exploded all api of excel.script and found NO anwser.
If you want to interactive function, script lab may useful.(https://learn.microsoft.com/en-us/office/dev/add-ins/tutorials/excel-tutorial?source=recommendations)
If you want to interactive function, script lab may useful.(https://learn.microsoft.com/en-us/office/dev/add-ins/tutorials/excel-tutorial?source=recommendations)
terryAnastassiadis
Mar 15, 2023Copper Contributor
Thanks for looking into it and your alternative recommendation! Add-ins where my next line of investigation so it's reassuring to get your suggestion. Much appreciated 👍
- peiyezhuMar 16, 2023Bronze ContributorYou are welcome.
below for your reference
https://learn.microsoft.com/zh-cn/javascript/api/excel/excel.worksheet?view=excel-js-preview#excel-excel-worksheet-onfiltered-member
onSelectionChanged
在特定工作表上更改所选内容时发生。
readonly onSelectionChanged: OfficeExtension.EventHandlers<Excel.WorksheetSelectionChangedEventArgs>;
事件类型
OfficeExtension.EventHandlers<Excel.WorksheetSelectionChangedEventArgs>- Michael-RussAug 23, 2024Copper Contributor
link to the English version of the reference page shared by peiyezhu above, rather than the Chinese:
- peiyezhuMar 16, 2023Bronze Contributor
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Sample");
sheet.onSelectionChanged.add(function (event) {
return Excel.run(async (context) => {
console.log("The selected range has changed to: " + event.address);
await context.sync();
});
});
await context.sync();
});// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet.yaml await Excel.run(async (context) => { let sheet = context.workbook.worksheets.getItem("Sample"); sheet.onChanged.add(onChange); await context.sync(); console.log("Added a worksheet-level data-changed event handler."); });
- terryAnastassiadisMar 16, 2023Copper Contributorpeiyezhu, thanks again, I took a look at the documentation. It's pretty straightforward, the only logistics I would have to tackle is hosting the manifest file as I would have to clear this first with our IT department.