有没有办法使用 ExcelScript (Excel for web) 进行事件处理

发布于 2025-01-13 15:56:34 字数 933 浏览 4 评论 0原文

我正在尝试使用 Excel for Web (ExcelScript) 创建一个“签到 - 签出”表单来登记公司员工的进出时间。对于表单中的每个工作人员,相邻行中必须有一个签入和一个签出按钮,该按钮将在按钮下方的单元格中标记当前时间,并删除该按钮,就像通常使用 VBA 宏完成的那样。

了解按钮不能从 javascript API 使用,但这个答案有一个有趣的解决方法,使用事件 worksheet.onSingleClicked () 因此,用户可以单击一个看起来像按钮的单元格,它将调用一个函数来标记当前时间并删除所有按钮格式。

Excel Javascript API 文档< /a> 有 worksheet.onSingleClicked()onChanged(),但我在 上找不到类似的内容href="https://learn.microsoft.com/en-us/javascript/api/office-scripts/excelscript?view=office-scripts" rel="nofollow noreferrer">ExcelScript 文档,据我了解是唯一可以在 Excel for Web 上运行的 API。

有没有办法在 for 循环中创建用户可交互按钮,或注册事件(如 onSingleClicked() 或 onChanged())在 Excel for Web 中使用?

谢谢

I am trying to create a "check in - check out" form to register the time in and out of workers at a company, using Excel for Web (ExcelScript). For every worker in the form, there has to be in the adjacent rows a Check IN and a Check OUT button that will stamp in the cell underneath the button the current time, and delete the button, as it was usually done with VBA macros.

In understand that buttons cannot be used from the javascript API but this answer has an interesting workaround using event worksheet.onSingleClicked() so the user would click on a cell that looks like a button, and it will call a function to stamp the current time and remove all button formatting.

The Excel Javascript API docs has the worksheet.onSingleClicked() or onChanged(), but I cannot find anything similar on the ExcelScript docs, which I understand is the only API that can run on Excel for Web.

Is there any way to create user interactable buttons in a for loop, or to register events (like onSingleClicked() or onChanged()) to be used in Excel for Web?

Thanks

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

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

发布评论

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

评论(2

鸢与 2025-01-20 15:56:35

您可以在 Excel Online 中使用 Excel Javascript API,而无需从头开始编写加载项。因此,您可以使用您提到的技巧,将单元格格式设置为看起来像按钮,这是我写的。它需要 JADE 插件,该插件可在 Mac Windows 和在线平台上运行,并且是免费的。它尚不适用于移动版本,但您可以在大多数(所有?)移动平台上运行在线版本。

使用 JADE,您可以将单元格格式化为工作表上的按钮,或者让代码在插件面板中使用实际签入/签出按钮呈现员工列表。

我很乐意编写这两种方法的示例,但它可能应该专门针对有关如何使用 JADE 插件执行此操作的问题作出回应。如果您想要这样的示例,请发布另一个问题并链接到此答案的评论,我将编写示例。

Disalimer:我编写了 JADE 插件。

You can use the Excel Javascript API in Excel Online without writing an add-in from scratch. So you could us the trick you mention that formats a cell to look like a button, which I wrote. It requires the JADE addin, which works on Mac Windows and Online platforms and is free. It does not yet work for mobile versions, but you can run the Online version on most (all?) mobile platforms.

Using JADE, you could either format the cells to look like buttons on the sheet or have the code render a list of employees with actuall check-in / check-out buttons in the addin panel.

I'd be glad to write and example of either approach, but it probably should be in response to a questions specifically about how to do this with the JADE add-in. If you want such an example, post another question and link to in a comment to this answer and I'll write the example(s).

Discalimer: I wrote the JADE add-in.

巴黎盛开的樱花 2025-01-20 15:56:34

您需要手动添加。现在新的 Office 脚本非常有限。但您可以向团队发布功能请求。

当开发团队完成规划过程时,会考虑技术社区上的功能请求。使用 github 标签:“类型:产品功能请求”,位于 https://aka.ms/M365dev-suggestions。

You need to add manually. New Office scripts are quite limited nowadays. But you may post a feature request for the team.

Feature requests on Tech Community are considered, when the dev team go through the planning process. Use the github label: “Type: product feature request” at https://aka.ms/M365dev-suggestions .

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