如何发布单个 Google 脚本函数?

How do I publish a single Google Scripts function?

所以我有一个功能,我想为我的 Google 工作表的 ALL 提供。

很简单。很简单,我将post完整地放在这里。

function swapMonthAndDay() {
  // The code below will swap the month and day for any Date objects in the selected cells.
  var range = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getActiveRange()
  var values = range.getValues();
  values.forEach(function(row, y){
    row.forEach(function(value, x){
      if (value instanceof Date){
        var month = value.getMonth() + 1,
            day = value.getDate();
        value.setMonth(day - 1);
        value.setDate(month);
      }
    });
  });  
  range.setValues(values)
}

我能够通过 运行 菜单中的 "test as add-on..." 获得我想要的结果。但正如术语 "test" 所暗示的那样,这是暂时的。因此,这让我相信我需要将其发布为表格插件。但是,我真的不想将其发布到网上商店。太多的步骤、身份验证、证书等无法到达那里。

好吧,我终于想通了。

事实证明,它与 Chrome 网上商店无关。有 GSuite Marketplace 和陈旧且贬值的 Chrome 网上商店。目前,部署为附加按钮链接到 Chrome 网上商店部署流程。

这一切都取决于云项目设置。

https://developers.google.com/gsuite/add-ons/how-tos/publish-addons

https://developers.google.com/gsuite/add-ons/how-tos/publish-for-domains

需要在编辑脚本时通过菜单中的Resources > Cloud Platform project...访问。