要复制并将表单选项卡“表单”中的所有非空行附加到另一个表单选项卡“保留”,然后从“表单”中删除数据。 我试过这个。:
// form copy
function formcopy(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Form");
var data = sheet.getDataRange().getValues();
for (var i = 2; i < data.length; i++) {
Logger.log('Timestamp: ' + data[i][0]);
Logger.log('Teacher Email: ' + data[i][1]);
Logger.log('Teacher Requesting: ' + data[i][2]);
Logger.log('Student: ' + data[i][3]);
Logger.log('Purpose: ' + data[i][4]);
Logger.log('Email: ' + data[i][5]);
Logger.log('Date: ' + data[i][6]);
Logger.log('Advisor: ' + data[i][7]);
Logger.log('Time: ' + data[i][8]);
Logger.log('Message: ' + data[i][9]);
Logger.log('Merge Status: ' + data[i][10]);
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Hold");
sheet.appendRow([data[i][0], data[i][1], data[i][2], data[i][3],
data[i][4], data[i][5], data[i][6], data[i][7], data[i][8], data[i][9],
data[i][10]]);
}}
//Deletes Data
function deletedata(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Form");
sheet.activate();
sheet.deleteRows(3,200);
sheet.insertRowsAfter(2, 200);
sheet.deleteRows(3);
}
它会复制数据,但也会复制空白行。此外,如果“表单”中有大量数据,则超时。