Google Apps Script Spreadsheet Comment Automation

前端 未结 3 1637
野性不改
野性不改 2020-11-27 20:00

Today I have a question about Google Apps Scripts, specifically for Spreadsheets. I\'ve already looked at the documentation here (yes, documentation on a Sheet<

3条回答
  •  独厮守ぢ
    2020-11-27 20:24

    There is no way to manipulate Comments via Spreadsheet Services - see Issue 36756650. (Star it if you wish.)

    Instead, all the "Comments" methods work on Notes.

    The following method will append a new "Modified" timestamp to any existing one - not quite as nice looking as an actual Comment would be, unfortunately.

    function onEdit() {
      var sheet = SpreadsheetApp.getActiveSpreadsheet();
      var cell = sheet.getActiveCell();
      var comments = cell.getComment();
      // Newline works in msgBox, but not in Note.
      comments = comments + "\\nModified: " + (new Date());
      //Browser.msgBox(comments);
      cell.setComment(comments);
    }
    

提交回复
热议问题