Javascript 如何在Google电子表格中放置来自不同源表的注释

Javascript 如何在Google电子表格中放置来自不同源表的注释,javascript,google-apps-script,google-sheets,Javascript,Google Apps Script,Google Sheets,我一直在努力寻找一种方法,将一个单元格(一系列单元格)中的信息作为注释放在另一张工作表中的另一个单元格(一系列单元格)中 类似这样,如果我在表格1的单元格A1中有苹果,我希望苹果作为注释插入表格2中的单元格F1中 我试着想出这样的办法 //I'm still working on this I have not been able to make this work// //Ideally this will put the phone numbers as comment's in the n

我一直在努力寻找一种方法,将一个单元格(一系列单元格)中的信息作为注释放在另一张工作表中的另一个单元格(一系列单元格)中

类似这样,如果我在表格1的单元格A1中有苹果,我希望苹果作为注释插入表格2中的单元格F1中

我试着想出这样的办法

//I'm still working on this I have not been able to make this work//
//Ideally this will put the phone numbers as comment's in the needed cases//
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var targetsheet = ss.getSheetByName("report");
 var sourcesheet = ss.getSheetByName("Sheet1");
 var nrange = sourcesheet.getRange(2, 3, sourcesheet.getLastRow(), 1)
 var sourcenotes = [nrange.getValue()]
 var notes = targetsheet.getRange(2, 6, sourcesheet.getLastRow(),1)
 notes.setNotes(sourcenotes);
正如你们所看到的,这不起作用,我尝试了不同的方法,但都不起作用,所以我来向你们寻求帮助。

函数“setNotes”采用一个二维数组,其值应该类似于setNotes([sourcenotes])。检查一下

另外,如果只为一个单元格设置注释,我建议使用函数setNote。是该函数的一个示例