In search for an answer to this question, I came up with the next workaround:
- apply filters in the sheet;
- color the filtered (and therefore
visible) cells (in the example code red in column F);
- run script:
- reading background colors (of column F) in array colors
- iterating this array
- building up the new array of row numbers that are visible.
This last array can be used to further manipulations of the sheet data.
To vivualize the effect of the script, I made the script setting the background of used cells to green.
It's one extra small effort for the end user to make, but IMHO it's the only way to make it possible to only use the filtered data.
function getFilterdData(){
var s = SpreadsheetApp.getActive();
var sheet= s.getSheetByName('Opdrachten en aanvragen');//any sheet
var rows = new Array();
var colors = sheet.getRange(1, 6, sheet.getLastRow(), 1).getBackgrounds();
for(var i = 0; i < colors.length; i++){
if(colors[i] == "#ff0000"){
var rowsIndex = rows.length;
rows[rowsIndex] = i+1;
sheet.getRange(i+1, 6).setBackground("#d9ead3")
}
}
}