Querying Google sheets from GAS with SQL and Filtered rows
From a GAS script I perform a query
var query = "SELECT *";
var queryUrl = 'https://docs.google.com/spreadsheets/d/' + ssheetID + '/gviz/tq?tqx=out:' + formatType + '&headers=1&sheet=' + sheetName + '&range=' + ColumnStart + ":" + ColumnEnd + '&tq=' + encodeURIComponent(query);
var res = UrlFetchApp.fetch(queryUrl, {headers: {Authorization: 'Bearer ' + ScriptApp.getOAuthToken()}}).getContentText();
If the excel columns are filtered, the filtered content and not the overall one is queried.
Unfiltered sheet:
Query result:
8:16:45 PM Info [[Row 1, Row 2, Row 3], [1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]
(Correct)
Using a Filter (Row 3 is filtered out)
This is a Mess, that means if I do a filter to check some data, another user will have umpredictable results.
Can anybody confirm this the only possible behaviour ? any lightweight workaround?
Comments
Post a Comment