Office js Excel.run with DelayForcelEdit不起作用

Office js Excel.run with DelayForcelEdit不起作用,office-js,Office Js,Excel.run({delayForCellEdit:true},async(context)=>{})仅在传递给它的函数中使用上下文 在嵌套的情况下Excel.run({delayforceledit:true},async(context)=>Excel.run(async(context2)=>{})}), 如果用户处于单元格编辑模式,则与context2相关的操作不会延迟 如果用户在脚本运行期间进行编辑,则以下脚本将抛出单元格编辑模式错误 async function run(

Excel.run({delayForCellEdit:true},async(context)=>{})
仅在传递给它的函数中使用上下文

在嵌套的情况下
Excel.run({delayforceledit:true},async(context)=>Excel.run(async(context2)=>{})})
, 如果用户处于单元格编辑模式,则与
context2
相关的操作不会延迟

如果用户在脚本运行期间进行编辑,则以下脚本将抛出单元格编辑模式错误

    async function run() {
      console.log("Now, double click a cell to enter edit mode!");
      await new Promise((resolve) => {
        setTimeout(resolve, 3000);
      });
      console.log("Start execute! please ensure the you are in cell edit mode!");
      await Excel.run({ delayForCellEdit: true }, async (context) => {
        return Excel.run(async (context2) => {
          context2.workbook.getActiveCell().values = [[0]];
        });
      });
    }
    /** Default helper for invoking an action and handling errors. */
    async function tryCatch(callback) {
      try {
        await callback();
      } catch (error) {
        // Note: In a production add-in, you'd want to notify the user through your add-in's UI.
        console.error(error);
      }
    }

这种行为是故意的。只需取消嵌套调用,或标记嵌套的
Excel。使用
delayforceledit
标志运行