5

I have an Excel containing cell comments/notes, I've uploaded it to Google Drive, and converted it into a Google Spreadsheet. How may I retrieve the comments for cell A1?

The API doesn't describe how to get a note or comment from a cell.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Kokizzu
  • 24,974
  • 37
  • 137
  • 233
  • 1
    Did you try https://developers.google.com/drive/v2/reference/comments/get and https://developers.google.com/drive/v2/reference/comments/list . You can get list of comments in a spread sheet, and you can get particular comment too. But you should use Drive API. I dont think with spread sheets API you can do this. – SGC Sep 04 '15 at 17:49
  • As of October 2019, it is still only possible to interact with notes, not with comments! – Cornelius Roemer Oct 21 '19 at 15:26

4 Answers4

6

The Google Apps Spreadsheet API only provides programmatic access to spreadsheet data. You cannot access comments using the API.

You can get the Notes for a cell or range of cells using Google Apps Script. See the Class Range documentation for these methods:

  • getNote() - Returns the note associated with the given cell.
  • getNotes() - Returns the notes associated with the cells in the range.

There are open issues related to this functionality, mainly concerning comments (the "other" type of note). See Issue 1818 and Issue 2566

In a comment on your question, SGC asks if you've looked at developers.google.com/drive/v2/reference/comments/get and developers.google.com/drive/v2/reference/comments/list; these are FILE level comments, not the comments attached to a spreadsheet cell.

Cooper
  • 59,616
  • 6
  • 23
  • 54
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
3

Bit of a muck around but it's possible to download the googlesheet as a .xlsx file, which, with varying degrees of success, converts the comments into Excel comments.

Uploading this xslx file converts the comments to notes!

Comments-to-Notes

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Nick_Jo
  • 101
  • 9
  • 1
    'Unfortunately' Google has since fixed this conversion bug and now Excel comments are converted to comments instead of notes. – Laurens Sep 30 '20 at 11:38
3

1 - Add the following custom function to your spreadsheet (through the Tools -> Script Editor menu)

function getNote(cell) {
return SpreadsheetApp.getActiveSheet().getRange(cell).getComment()
}

2 - on your spreadsheet use the following formula to get contents

=getNote(cell("address",a1))

or

=getNote(cell("address",E9),GoogleClock())

if your comments are not static.

Oren Pinsky
  • 419
  • 3
  • 19
  • Couldn't get this to work - I get an error ("loading data") as the script is executed. My use case is to change color of a cell if a comment is present, BTW. – Mr Printer May 27 '19 at 02:21
0

There is a difference between Note and Comment. getNote is working fine. You create a Note by using the cell menu "insert Note" , and not "insert Comment"

Very sad, but there is no getComment. The example of Oren did not work for me either.