gpt4 book ai didi

excel - 注册 onSelectionChange

转载 作者:行者123 更新时间:2023-12-04 21:49:33 25 4
gpt4 key购买 nike

在过去的几天里,我一直在尝试为基于 VUE 的 excel 制作任务 Pane 插件。

我已按照 link 的指南进行操作我试图为 onSelectionChange 注册一个事件处理程序。它已经有些成功,但似乎它在一段时间后将事件排队。然后我必须悬停任务 Pane 或执行 ctrl+c 之类的操作才能执行排队的代码。

我是 JS 和 Vue 的新手,所以我很可能错过了重要的上下文。

我的代码如下:

import Vue from 'vue'
import App from './App'

Vue.config.productionTip = false

/* eslint-disable no-new */

const Office = window.Office
Office.onReady()
.then(
registerSelectionChange(), // moved in here based on input from Rick
new Vue({
el: '#app',
components: {App},
template: '<App></App>'
})
)

async function registerSelectionChange() {
return await Excel.run(async function (context) {
let ws = context.workbook.worksheets.getActiveWorksheet();
ws.onSelectionChanged.add(handleSelectionChange);
return await context.sync()
})
}

async function handleSelectionChange(event){
return await Excel.run(async function(context){
let ws = context.workbook.worksheets.getActiveWorksheet();
let range = ws.getRange(event.address)
range.values = [[1]]
return await context.sync()
})
}

最佳答案

我现在发现registerSelectionChange() 有问题。 .解决方法是添加 <script> MutationObserver=null; </script>在节中。
更多信息 here .

关于excel - 注册 onSelectionChange,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57408810/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com