function getIndexesOfFilteredRows(ssId, sheetId) { var hiddenRows = []; // limit what's returned from the API var fields = "sheets(data(rowMetadata(hiddenByFilter)),properties/sheetId)"; var sheets = Sheets.Spreadsheets.get(ssId, {fields: fields}).sheets; for (var i = 0; i < sheets.length; i++) { if (sheets[i].properties.sheetId == sheetId) { var data = sheets[i].data; var rows = data[0].rowMetadata; for (var j = 0; j < rows.length; j++) { if (rows[j].hiddenByFilter) hiddenRows.push(j); } } } return hiddenRows; }
function setSheetBasicFilter(ssId, BasicFilterSettings) { //requests is an array of batchrequests, here we only use setBasicFilter var requests = [ { "setBasicFilter": { "filter": BasicFilterSettings } } ]; Sheets.Spreadsheets.batchUpdate({'requests': requests}, ssId); }