I've been doing some research and for some reason can't find a good example showing this anywhere, and I am starting to wonder if it's even possible.
What's I'm looking to do is to have my extension write data within a Google Spreadsheet, so that the sheet is being used as a database.
Does anyone have any documentation that I could follow through? Considering that the Spreadsheet API doesn't seem to allow JavaScript, is that even possible?
THanks.
Yes, it is definitely possible. I have used the Spreadsheet API extensively using Javascript. You'll need to use the Protocol version of the API as documented here: https://developers.google.com/google-apps/spreadsheets/
This requires sending signed requests using OAuth2 (the older auth protocols aren't really reliable anymore.) so I suggest using an OAuth2 library like JSO. https://github.com/andreassolberg/jso
When writing your javascript you'll need to write functions that create an XML string to interface with the Protocol API. Parsing the responses is pretty straight forward. I've included a snippet of the code I've used. You can also see my answer to a related question using JQuery here. JQuery .ajax POST to Spreadsheets API?
I think you are having same question which I had some months ago. I was looking for some library to do same but couldn't found any so I end up with creating one called gsloader. I am using this library in this jiraProgressTracker chrome extension. Chrome extension is under development but gsloader library is ready to use.
Here is what you need to do.
Following is some code snippet to go with.
// Do Authorization
var clientId = "<your client id>";
GSLoader.setClientId(clientId);
// Load existing spreadsheet
GSLoader.loadSpreadsheet("spreadsheet id");
// Create spreadsheet
GSLoader.createSpreadsheet("spreadsheet id")
There are enough methods and objects available to work with, rather than mentioning all here I will try to make documentation available.
Please let me know, how does it works with you overall.