Is there a way to get a range of values filtered by a slicer/multiple slicers using App Script? My understanding is that slicers work like a filter view which are not "hard" filters. I tried .getRange().getValues() but it returns all the data without the slicers being applied.
I have a source data in one sheet and a pivot table with slicers in another sheet. I want the user to open the sheet with the pivot table, filter the table using the slicers and then run a script which would get the filtered range from the table.
Using the below code I see that the script gets all the data even when the slicers are applied:
var activeSheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var vals = activeSheet.getRange("A2:A").getValues();
var numOfResults = vals.filter(String).length;
Logger.log(numOfResults);
Test sheet: https://docs.google.com/spreadsheets/d/1pmazwEQp37Dkz41X2EjHmHEpONKqBD4g-Zhq0KuBYdU/edit?usp=sharing
Thanks a lot for any help!