使用Excel JavaScript API将焦点从Taskpane转移到工作表

发布于 2025-01-23 06:14:34 字数 642 浏览 1 评论 0 原文

我正在使用Excel JavaScript API进行Excel添加。

有没有办法将焦点从Taskepane切换到工作表?现在,如果用户单击Taskpane上的元素,她将无法使用箭头键来导航Excel表,直到她再次使用鼠标单击了纸板区域为止。

用例
在Taskpane上有一个按钮,可以将文本粘贴到表格上的一定范围,并且还将将焦点移至表格上,这是很不错的,因此在按下按钮后,用户可以立即开始使用箭头键导航。

将文本粘贴到范围并设置选择效果很好,但是我找不到使用JS API将焦点从Taskpane转移到工作表的方法。

非常感谢任何帮助,
谢谢你!

I am working on an Excel Add in using Excel Javascript API.

https://learn.microsoft.com/en-us/office/dev/add-ins/reference/overview/excel-add-ins-reference-overview

Is there a way to switch focus from taskpane to the sheet? Now if user clicks on an element on the taskpane she cannot use the the arrow keys to navigate the excel sheet until she has clicked the sheet area again with the mouse.

Use case
It would be nice to have a button on the taskpane that would paste text to a certain range on the sheet and would also move the focus to the sheet, so the user could start navigating with arrow keys immediately after pressing the button.

Pasting the text to the range and setting the selection are working fine, but I cannot find a way to move focus from the taskpane to the sheet with JS API.

Any help is very much appreciated,
Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

入画浅相思 2025-01-30 06:14:34

最好的办法是尝试设置活动工作表

await Excel.run(async (context) => {
    let sheet = context.workbook.worksheets.getItem("Sample");
    sheet.activate();
    sheet.load("name");

    await context.sync();
    console.log(`The active worksheet is "${sheet.name}"`);
});

如果这不是您想要的,我建议您在此处提交功能请求: https://aka.ms/m365dev-suggestions

The best what you could do is to try to Set the active worksheet:

await Excel.run(async (context) => {
    let sheet = context.workbook.worksheets.getItem("Sample");
    sheet.activate();
    sheet.load("name");

    await context.sync();
    console.log(`The active worksheet is "${sheet.name}"`);
});

If this isn't what you are looking for, I'd suggest you to file a feature request here: https://aka.ms/M365dev-suggestions .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文