如何为 google 应用程序脚本表附加组件编写清单文件

How to write a manifest file for google apps script sheets add-on

我正在尝试发布 google 张纸的附加组件。

当我点击工作表边栏中的加载项图标时,错误消息是:

没有为宿主应用提供首页卡片:Google张。

appsscript.json

{
  "timeZone": "Europe/Paris",
  "dependencies": {
    "enabledAdvancedServices": [
      {
        "userSymbol": "Sheets",
        "version": "v4",
        "serviceId": "sheets"
      }
    ]
  },
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8",
  "addOns": {
    "sheets": {}
  }
}

No homepage card is provided for the host app: Google Sheets.

您应该在 appsscript.json 中添加一个 homepageTrigger,它使用您的边栏代码调用一个函数:

像这样:

{
  "timeZone": "America/New_York",
  "dependencies": {},
  "exceptionLogging": "STACKDRIVER",
  "oauthScopes": [
    "https://www.googleapis.com/auth/spreadsheets.currentonly",
    "https://www.googleapis.com/auth/script.container.ui"
  ],
  "runtimeVersion": "V8",
  "addOns": {
    "common": {
      "name": "Translate",
      "logoUrl": "https://www.gstatic.com/images/branding/product/1x/translate_24dp.png",
      "layoutProperties": {
        "primaryColor": "#2772ed"
      },
      "homepageTrigger": {
        "runFunction": "buildSideBar"
      }
    },
    "sheets" : {}
  }
}

然后在你的 code.gs 文件中写入你的函数 buildSidebar() {}