office-js - Office 插件 - context.runtime.load("enableEvents") 在 Window 中不起作用
问题描述
我正在尝试打开/关闭事件处理程序,context.runtime.load("enableEvents");
但是在使用 Excel 2016 或更早版本的 Window 中的插件时遇到以下错误。
NotImplemented: This operation is not implemented.
我认为这个问题与 Internet Explorer 有关。在 Mac(任何 Excel 版本)或 Window(Excel 2019 或更高版本)中运行我的插件时,我没有这个问题。
重现:以下代码是此处找到的 Excel 插件的示例代码。只需添加该行context.runtime.load("enableEvents");
,就会出现错误。
export async function run() {
try {
await Excel.run(async (context) => {
/**
* Insert your Excel code here
*/
const range = context.workbook.getSelectedRange();
// Read the range address
range.load("address");
// Update the fill color
range.format.fill.color = "yellow";
///////// New code. Adding this line will cause error
context.runtime.load("enableEvents");
await context.sync();
console.log(`The range address was ${range.address}.`);
});
} catch (error) {
console.error(error);
}
}
解决方案
推荐阅读
- javascript - Jquery 总是返回“jQuery.fn.init [global]”。我无法选择元素
- javascript - JavaScript 对象引用
- wpf - 由按钮触发时从屏幕边缘滑动的 WPF 应用程序
- javascript - OAuth2 的“/usercallback”在已发布的 Google Addon 上作为 HEAD 运行
- javascript - 无法使过滤器与 Immer.js 一起使用以删除数组中的嵌套对象
- android - 没有 OpenCV 的 Android 图像矩形检测
- laravel - Laravel Nova 将文件保存为 base64
- algorithm - 为每个 M 团队负责人组成 K 成员团队的算法
- laravel - 调用数据表中的数据时参数名称未知
- javascript - 为什么这些 js 对象字面量会被冻结?