How to programmatically create a Google Docs spreadsheet WITH CONTENT?

Steve Perkins picture Steve Perkins · Jan 19, 2014 · Viewed 12.8k times · Source

I have found multiple StackOverflow questions dealing with how to create or edit Google Doc spreadsheets using the Google Spreadsheets API, or older API's. However, this Spreadsheets API seems to be part of the "gdata" library, which to my understanding is deprecated.

Newer StackOverflow answers show how to create an empty spreadsheet using the Drive API, which seems more current. However, from looking at the documentation and examples for that API, it seems to only let you create new EMPTY files with the spreadsheet MIME type. I have not found any functionality for creating a spreadsheet with actual content (i.e. rows, columns, worksheets, etc).

What is the current process for creating a new Google Doc spreadsheet AND populating it with content? Does the Drive API have functionality that I'm not understanding? Is the "gdata" library (or at least its Spreadsheets API portion) not completely deprecated after all? Is there some third approach that I've missed altogether? I'm working with Java code, to the extent that matters, although I'm sure that any Python API would have a Java equivalent.

Answer

pinoyyid picture pinoyyid · Jan 19, 2014

Answer in bullet form ...

  • It's only the old docslist API which is deprecated. The spreadsheet API is still alive and kicking since there is no replacement
  • The gdata libs are possibly no longer supported, but you will probably be better served using the spreadsheet API directly anyway
  • The Drive API is only concerned with operations at the whole file level
  • You could create a populated spreadsheet using the Drive API by uploading a file in a format that can be converted to a Google Spreadsheet, eg. MS Excel
  • Be aware that the spreadsheet API (and possibly the Drive API) do not yet support the new (end 2013) spreadsheet format