arrow_backward Back to blog

Retrieving Comments from Google Spreadsheets

![cell comments](

In a recent project, Intridea utilized Google Spreadsheet as a major data source, using Roo::Google in [Roo Gem]( to access the spreadsheet and [Google Drive Ruby Gem]( to communicate with [Google Spreadsheet API v3](

It’s a great tool for data source management. However, when we attempted to access the individual cell comments, the export capabilities proved difficult…

![cell comments](

The cell comments feature isn’t exposed by [Google Spreadsheet API v3](,
thus, retrieving these comments via Roo::Google in [Roo Gem]( became futile.

After some googling though, we discovered this wasn’t an isolated incident.

One suggestion we found was utilizing cell notes; a predecessor to Google comments. However, while useful, cell notes lacks necessary commentator information. In addition, when generating Google’s html code, the spreadsheet malformats and had difficulty linking notes back to cells.

Below is an example of the html export. Notice most table cells are not closed.





Slide table
[1] cell note


After further research though, we discovered a solution; exporting the spreadsheet in XLSX format.

XLSX file is actually just a zip file, and when unzipped there are a series of files. One of these files being, comments1.xml; a file with all the XLSX content we’d been looking for!

![xlsx content](


cell note
testing comments -Ping Yu


Initially, due to a slight variance between what Google generated and what Roo expected, Roo::Excelx reader in [Roo Gem](, couldn’t find any of the comments.

However, after we submitted a [PR here]( we were able to retrieve the comments. You can use our [repo]( before the PR is merged.

Here is the code snippet for exporting the spreadsheet and retrieving the comments:

drive = GoogleDrive.login("", "mypassword")

  path =
    Dir::Tmpname.make_tmpname("#{Rails.root}/tmp/raw", nil) + ".xlsx"

  # example google spreadsheet url
  drive.spreadsheet_by_key("pz7XtlQC-PYx-jrVMJErTcg").export_as_file(path, "xls"), comment_xpath: './xmlns:text/xmlns:t').comments
  #[[129, 60, "New comment"], [156, 5, "commentsnt-Ping Yu"]]

tag , ,


New Project Request