Office js 如何在Office Web加载项中注册设置更改事件的处理程序

Office js 如何在Office Web加载项中注册设置更改事件的处理程序,office-js,office-addins,Office Js,Office Addins,我正在尝试使用Excel 1.4要求集中的Excel.Setting和Excel.SettingCollection对象。(不是来自shared Office.js API的旧设置对象。)我无法获取要注册的Excel.SettingCollection.onSettingsChanged事件的处理程序。下面是我的代码(TypeScript)。我运行createSetting方法,并已验证是否正在添加我的设置。然后我运行changeSetting方法。没有错误,但我的处理程序从不运行。有人知道怎么

我正在尝试使用Excel 1.4要求集中的Excel.SettingExcel.SettingCollection对象。(不是来自shared Office.js API的旧设置对象。)我无法获取要注册的Excel.SettingCollection.onSettingsChanged事件的处理程序。下面是我的代码(TypeScript)。我运行
createSetting
方法,并已验证是否正在添加我的设置。然后我运行
changeSetting
方法。没有错误,但我的处理程序从不运行。有人知道怎么了吗?添加第二个设置和删除设置也不会触发处理程序。(其他Excel 1.4 API工作正常。)

处理程序:

async function onChangedSetting() {
    try {
        await Excel.run(async (context) => {
            console.log("handler ran");  // DOES NOT RUN
            await context.sync();
        });
    }
    catch (error) {
        console.log(error.message);
    }
} 
更改设置方法:

async function changeSetting() {
    try {
        await Excel.run(async (context) => {
            const settings = context.workbook.settings;

            // The settings.add function is also how you change a 
            // setting. There is no Excel.SettingCollection.setItem
            // or Excel.Setting.set method.
            settings.add("NeedsReview", false); // Change value
            await context.sync();
        });
    }
    catch (error) {
        console.log(error.message);
    }
}

我知道这是一个已知的错误。使用新的1.4 API更改设置时,不会触发
onSettingsChanged
事件。修复后,我将在此更新。

相关GitHub问题:。
async function changeSetting() {
    try {
        await Excel.run(async (context) => {
            const settings = context.workbook.settings;

            // The settings.add function is also how you change a 
            // setting. There is no Excel.SettingCollection.setItem
            // or Excel.Setting.set method.
            settings.add("NeedsReview", false); // Change value
            await context.sync();
        });
    }
    catch (error) {
        console.log(error.message);
    }
}