I am using Google App scripts and am having trouble finding an answer to this fairly simple task: how can I get the data from a Google Sheet in my code.gs and then use it in a published web app (for some visualization w/ D3)?
I would like to get all columns and rows from the spreadsheet, then use those in the data. Preferably they would be in JSON for ease of use, but I can't find the specifics on how to grab all (or any) of the data from a Sheet in my code.gs and then use it in the index.html.
So far I have something like this:
code.gs
function getData(){
var sheet = SpreadsheetApp.openById("1NCNsdEGAHXWhZMEHnOflsIqElKdQSQxy83iM5vUIa9k");
//get desired range
return sheet;
}
index.html
In the <script>
in index.html:
google.script.run.getData();
But am otherwise at a loss. Thanks for any help.