I am trying to apply filter to a Excel table using office scripts and copy the data to a new worksheet. I am using getVisibleView() but it pastes all data to new worksheet, and not just the filtered rows.
table1 = workbook.getTable("Table1");
// Apply checked items filter on table table1 column Logged in Last 120 Days?
table1.getColumnByName("Logged in Last 120 Days?").getFilter().applyValuesFilter(["YES"]);
// Add a new worksheet
let QuarterMapping = workbook.addWorksheet(QuarterMappingSheetname);
const source = table1.getRange().getVisibleView().getRange();
// Copy the data into the other sheet.
const otherRangeCorner = QuarterMapping.getRange("A1");
otherRangeCorner.copyFrom(source, ExcelScript.RangeCopyType.all);