You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Excel for the Web脚本事件是否支持?附示例代码

Excel for Web是否支持Office Scripts事件功能?

Excel for Web的Office Scripts不支持事件触发机制,仅桌面版Excel(Windows/macOS)支持onActivated这类工作表事件绑定。

你提供的代码逻辑本身无问题,但受Web版API限制,这类事件监听无法生效。若需使用事件触发的自动化逻辑,只能在桌面端Excel中运行对应的Office Scripts。

示例代码:

const sheet = context.workbook.worksheets.getItem("Sample");
sheet.onActivated.add(function (event) {
  return Excel.run(async (context) => {
    console.log("The activated worksheet ID is: " + event.worksheetId);
    await context.sync();
  });
});
await context.sync();
});

内容的提问来源于stack exchange,提问作者laloune

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 18:10:32