将工作表中的数据放入任务窗格
我有一个任务窗格和我想从工作表中填写的字段之一。
如何在 Office 任务窗格启动期间访问工作表中的数据?
示例:
Office.onReady(function (info) {
const range = context.workbook.getSelectedRange();
// Read the range address
range.load("address");
// Update the fill color
range.format.fill.color = "yellow";
})
给出错误Context
未定义。
如何加载一些数据并在启动时将其发送到任务窗格?
一个简单的例子是,我有一个下拉列表,我想用列字母填充它,但只能从 usedrange
中填充。
I've got a taskpane and one of the fields I'd like to fill out from the worksheet.
How can I access data from Worksheets during Office Taskpane startup?
Example:
Office.onReady(function (info) {
const range = context.workbook.getSelectedRange();
// Read the range address
range.load("address");
// Update the fill color
range.format.fill.color = "yellow";
})
gives error Context
is undefined.
How can I load some data and send it up to the Taskpane on launch?
A simple example is, I have a Dropdown which I'd like to populate with column letters, but only from the usedrange
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您似乎正在尝试使用
Excel.RequestContext
对象。在调用它之前,您需要获得对它的引用。建议的方法是调用Excel.run
。它将自动创建context
对象并将其传递给回调。这是一个例子。It looks like you are trying to use the
Excel.RequestContext
object. You need to get a reference to it before you call it. The recommended way to do this is to callExcel.run
. It will automatically create thecontext
object and pass it to the callback. Here's an example.@RickKirkham 的回答帮助我指明了正确的方向。我必须将
async
添加到主函数中,然后我才能执行Excel.Run
之后需要的操作,例如:
@RickKirkham answer helped point me in the correct direction. I had to add
async
to the main func and then I was able to do what was needed afterExcel.Run
Eg: