发布 Google Sheet add-on 时,是否包括单元格格式?

When publishing a Google Sheet add-on, is cell formatting included?

我创建了一个 Google Sheet add-on,其中包括一堆 Google Apps 脚本以及一堆在许多工作表(选项卡)上的格式。当我将其发布到 G Suite Marketplace 时,工作表(选项卡)的格式是否会包含在内?例如,我输入了列 headers,设置了文本样式(颜色、字体等)。格式和文本指示用户在何处输入允许 add-on 运行所需的数据。

我搜索了文档和其他 Whosebug 问题,但没有找到答案。

已发布的 Google 表格插件不包含电子表格的副本。要包含它们,您可以让您的加载项创建包含格式化工作表的电子表格副本,或者您可以将该电子表格发布为模板。

参考

我找到了答案。 @Rubén 可能指的是这个解决方案。

要完成此操作,请按照下列步骤操作。

  1. 使用相关的格式、文本、颜色等创建您的跨页sheet
  2. 进入共享设置并使用选项 Anyone who has the link can view
  3. 共享点差sheet
  4. 然后获取 URL 中的传播 IDsheet(例如 https://docs.google.com/spreadsheets/d/ID_IS_HERE/edit#gid=0
  5. 要复制该传播sheet,请在您的插件中使用以下代码。

    function importSheet() {
        var ss = SpreadsheetApp.openById("sheet ID goes here");  
        var sheetToCopy = ss.getSheets()[0];  //gets the first sheet
        var destination = SpreadsheetApp.getActiveSpreadsheet();  
        sheetToCopy.copyTo(destination);  
    }  
    

如果你的源传播sheet有多个sheets,你可以使用var number = ss.getSheets().length;获得sheets的数量然后使用[=循环上面的代码13=]复制每个个体sheet.

关于来源传播sheet,Google 提供以下详细信息

// Note that the spreadsheet is NOT physically opened on the client side. // It is opened on the server only (for modification by the script).

我希望这对其他人有帮助。