【问题标题】:Using google spreadsheet values for a drop down in a Google Docs Side bar使用谷歌电子表格值作为谷歌文档侧栏中的下拉菜单
【发布时间】:2016-11-09 03:48:50
【问题描述】:

那里似乎没有多少 r.e.谷歌文档侧边栏。

除了 Mogsdad 的出色工作。

他的光标定位工具是我已经需要的 1/2 (How to poll a Google Doc from an add-on)。

我有一个 google 表格模板,其中包含大约 200 个可能的占位符,需要将它们放入 google 文档中,填充,然后 PDF'd。

我似乎在任何地方都找不到的是如何将范围从谷歌工作表获取到文档侧栏。这样,在构建模板时,我可以设置一些可变的动态下拉菜单,将正确的占位符放置在光标位置。

谁能指出我正确的方向? (是的,我知道 Autocrat :P)

【问题讨论】:

    标签: javascript html google-apps-script google-sheets google-docs


    【解决方案1】:

    使用 Google Apps 脚本 Spreadsheet service,首先打开电子表格,然后获取范围,最后获取值。

    例子:

    /**
     * Get the values from a range speficied by the Spreadsheet ID and the range reference or 
     * name
     *
     * @param {'1FkUd199CS3U25bfb5WxP-Jy--qcgD4NTHYWNMw8AtiA'} id Spreadsheet id
     * @param {'Sheet1!A1:A100'} stringReference Reference string
     * @return 2D array with the values of the specified range
     */
    function getSpreadsheetValues(id,stringReference){
      var ss = SpreadsheetApp.openById(id);
      var range = ss.getRange(stringReference);
      return range.getValues();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-30
      • 1970-01-01
      • 2014-07-01
      • 2011-03-31
      • 2017-04-28
      • 1970-01-01
      • 1970-01-01
      • 2015-10-15
      相关资源
      最近更新 更多