Google apps script 导入和导入注释?

Google apps script 导入和导入注释?,google-apps-script,Google Apps Script,我正在尝试导入注释和单元格值。我正在使用importRage()作为值。我还发现了下面的谷歌应用程序脚本,应该可以得到评论: function importComments(spreadsheetKey,a1NotationReference) { return SpreadsheetApp.openById(spreadsheetKey).getRange(a1NotationReference).getComments(); } 不过,每次运行它时,都会出现“缺

我正在尝试导入注释和单元格值。我正在使用importRage()作为值。我还发现了下面的谷歌应用程序脚本,应该可以得到评论:

    function importComments(spreadsheetKey,a1NotationReference) {
      return SpreadsheetApp.openById(spreadsheetKey).getRange(a1NotationReference).getComments();
    }
不过,每次运行它时,都会出现“缺少形式参数”错误

我也试过像这样运行,但没有运气/

    function importComments(0AqvTp4ajjRSUdHYyV09QcWtnRFQ2SDUwSTF6OTBKQ0E,Overall!B2:I2) {
      return SpreadsheetApp.openById(0AqvTp4ajjRSUdHYyV09QcWtnRFQ2SDUwSTF6OTBKQ0E).getRange(Overall!B2:I2).getComments();
    };

任何帮助都将不胜感激

您没有正确地调用该函数,下面是您添加到Google脚本管理器的内容。这不需要改变

function importComments(spreadsheetKey,a1NotationReference) {
      return SpreadsheetApp.openById(spreadsheetKey).getRange(a1NotationReference).getComments();
    }
然后使用下面的函数在电子表格中调用此函数。只需像普通电子表格一样输入单元格

=importComments("0AqvTp4ajjRSUdHYyV09QcWtnRFQ2SDUwSTF6OTBKQ0E", "Overall!B2:I2")
正如Henrique Abreu在Google论坛上提到的,这与importRange的工作原理非常相似。这将有助于解决重要问题

编辑两者的示例未测试


我不太确定,但它们是否需要是字符串文字?e、 g.
“0aqvtp4ajrsudhyyv09qcwtnrfq2sduwstf6otbkq0e”
“总体!B2:I2”
如果可能,可以提供一个链接到获取此脚本的页面,以便我们可以查看文档?我从so获得了脚本,importRange和importComments不能同时用于导入带有importRange的单元格并注释带有importComments的单元格?可能不会,但您可以创建第二个函数,用相同的参数调用这两个单元格。importComments和importComments都返回空单元格。链接页已消失:-(您如何处理授权?我的脚本无法授权,因为它需要权限-
您没有调用电子表格的权限。openById
function importBoth(spreadsheetKey,a1NotationReference){
   return SpreadsheetApp.openById(spreadsheetKey).getRange(a1NotationReference).getComments();
   return SpreadsheetApp.openById(spreadsheetKey).getRange(a1NotationReference).getValue();
}