How to identify the Excel Sheet changed event in office js api?

后端 未结 3 875
日久生厌
日久生厌 2021-01-16 07:57

We have an Excel office js add-in written on angular. It has different functionalities based on the sheet the user is in. When users switch the sheets of excel, how can the

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-16 08:17

    You can add handler for context.workbook.worksheets.onActivated

    Excel.run((context) => {
      context.workbook.worksheets.onActivated.add(({ worksheetId }) => {
        console.log('Selected worksheet', worksheetId)
      })
    
      return context.sync()
        .then(function () {
            console.log("Event handler successfully registered");
        });
    }).catch(errorHandlerFunction);
    

    More info here

提交回复
热议问题