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

How to place notes from different source sheet in Google Spreadsheets

本文关键字:工作 注释 Google 电子表格      更新时间:2023-09-26

我一直在努力寻找一种方法,将单元格(单元格范围)中的信息作为注释放置在不同工作表的不同单元格(单元格区域)中。

类似这样,如果我在第1张的单元格A1中有Apple,我希望Apple作为注释插入第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。下面是一个关于该函数的示例。