jquerygoogle-sheetsgoogle-apps-scriptweb-applications

How do you read cell values from a Google Drive Spreadsheet?


I want to read some simple parameters from a Google Drive Spreadsheet using Google Apps Script API and then return that value as part of the doPost() response in the GAS script to a javascript function I call from my local website.

I know how to write to a Speadsheet

function doPost(e) {
  var app = UiApp.getActiveApplication();

  SpreadsheetApp.openById(SPREADSHEET_ID).getSheetByName('RequestInvites').appendRow([e.parameter.emailAddress, 'hash123']);

  app.add(app.createLabel("Form submitted. Your email address is: '" + e.parameter.emailAddress));

  return app;
}

But I can't figure out how to read a value from a Spreadsheet and return a response to the calling script on my site (using jQuery's $.ajax() function)


Solution

  • Range.getValue() ?

    https://developers.google.com/apps-script/class_range#getValue

    To return a value. I suspect HTML service is the cleanest way. Although I came across a post showing how do it with by throwing an error.