谷歌应用程序脚本:如何在不使用getComment()方法的情况下将第二条注释添加到第一条注释中

Google Apps Script: how to adding a second comment to the first without using getComment() method

本文关键字:注释 脚本 二条 应用程序 一条 添加 情况下 getComment 方法 谷歌      更新时间:2023-12-19

我使用此代码在电子表格的单元格中编写注释:

var sheet = SpreadsheetApp.getActiveSheet();
  var currentRow = sheet.getActiveSelection().getRowIndex();
  var firstCell = sheet.getRange("A"+currentRow);
  firstCell.setComment(docName);

但我有一个问题:当我在同一行第二次使用并添加第二条注释时,第一条注释就不见了(被第二条评论取代)。我知道我可以用Class Range的不推荐使用的方法getComment()来解决它。是否有getComment()不推荐使用的替代方法?

setComment()也不推荐使用,您应该使用setNote()和getNote(