I am using a Google Script bound to a Google Sheet to programatically generate the following query:
=query('16 Jul - 20 Jul Responses'!A1:I31, "SELECT C WHERE D = 'Available'", 0)
Is there any way in Google Scripts to parse an object representation of that query's results? I'd like to be able to code something like:
var queryString = '=query('16 Jul - 20 Jul Responses'!A1:I31, "SELECT C WHERE D = 'Available'", 0)';
var results = new Query(queryString);
for(var i = 0; i < results.length; i++) {
var result = results[i];
// do something
}
As far as I can tell, the Query object doesn't exist unless you are working with a Google Web App. Is this true? Or is there a way to implement this idea?
=QUERY is a spreadsheet function. If you want that functionality in Apps Script you can leverage Google's Visualization API and Query Language. I wrote a custom module for it in GAS. Here's an extract:
Just drop that module into its own file in your GAS editor then you can call it as follows: