在 Excel 加载项上,函数参数助手未显示在我的加载项的 Web 浏览器上

问题描述 投票:0回答:1

我想要这样的东西:

enter image description here

但是在我的 Excel 加载项上没有显示,我正在使用 yo office 模板创建加载项。

问题:我需要做什么来显示这个帮助?

我希望再次在 excel 浏览器上工作。

excel office-js office-addins excel-web-addins custom-functions-excel
1个回答
1
投票

确保您为自定义函数包含了 JSON 元数据。阅读为自定义函数手动创建 JSON 元数据了解更多信息。

要使函数正常工作,您需要将函数的

id
属性与JavaScript 实现相关联。确保存在关联,否则该函数将不会被注册并且无法在 Excel 中使用。以下代码示例显示了如何使用
CustomFunctions.associate()
函数进行关联。该示例定义了自定义函数 add 并将其与 JSON 元数据文件中的对象相关联,其中
id
属性的值为
ADD
.

/**
 * Add two numbers
 * @customfunction
 * @param {number} first First number
 * @param {number} second Second number
 * @returns {number} The sum of the two numbers.
 */
function add(first, second) {
  return first + second;
}

CustomFunctions.associate("ADD", add);

以下 JSON 显示了与之前的自定义函数 JavaScript 代码关联的 JSON 元数据。

{
  "functions": [
    {
      "description": "Add two numbers",
      "id": "ADD",
      "name": "ADD",
      "parameters": [
        {
          "description": "First number",
          "name": "first",
          "type": "number"
        },
        {
          "description": "Second number",
          "name": "second",
          "type": "number"
        }
      ],
      "result": {
        "type": "number"
      }
    }
  ]
}

请注意,您可以在 Tech Community 上发布或投票支持现有功能请求,Office 开发团队在规划过程中会考虑这些请求。

© www.soinside.com 2019 - 2024. All rights reserved.