Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
358 views
in Technique[技术] by (71.8m points)

Bulk copy filtered rows from one google sheet to another google sheet

I have a spreadsheet where I am able to filter the sheet based on a value on a column. I can copy the filtered data using isRowHiddenByFilter. But this does it one row at a time. I am looking for some input on how I can copy say 200 rows that I obtain after using a filter to be copied to another spreadsheet all at once and not evaluating 200 rows.

This is what I have working:

var criteria = SpreadsheetApp.newFilterCriteria().whenTextContains("I do NOT 
           plan").build();
ss.getActiveSheet().getFilter().setColumnFilterCriteria(4,criteria);

var nrsheet = ss.getSheetByName("Not Returning");

for (var i = 2; i < sheet.getLastRow(); i++) 
{
  if(!sheet.isRowHiddenByFilter(i)) 
  {
    row_data = sheet.getRange(i, 1, 1, sheet.getLastColumn()).getValues();
    one_arr_nr = row_data.join().split(",");
    nrsheet.appendRow(one_arr_nr);
  }
}

This is what I would like to do: Remove the for loop to evaluate each row and be able to copy what I see on the spreadsheet to be copied to the Not Returning sheet. Any help on how I can proceed?

question from:https://stackoverflow.com/questions/65893006/bulk-copy-filtered-rows-from-one-google-sheet-to-another-google-sheet

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...