Google Apps Script Spreadsheet Comment Automation

前端 未结 3 1650
野性不改
野性不改 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:11

    Using Google Drive API in Google Apps Script, we could create Comments in a Google Document.
    And after a test, I confirm you can also do it in a Spreadsheet (which is normal because Comments depends only on Drive API)

    function insertDriveComment(fileId, comment, context) {
      var driveComment = {
        content: comment,
        context: {
          type: 'text/html',
          value: context
        }
      };
      Drive.Comments.insert(driveComment, fileId);  
    }
    

    Keep in mind that you cannot attach programmatically the comment to a cell (or to words in Google Document), because anchors for Document and Spreadsheet Comments are proprietary (check the video at the bottom of the page here)

    Hope it could help.

提交回复
热议问题