我试图在第一个可用的免费行之后将一个Google表格数据复制到其他Google表格。
function CopyDataToNewFile() {
var sss = SpreadsheetApp.openById('1vHc........'); // sss = source spreadsheet
var ss = sss.getSheetByName('Database'); // ss = source sheet
//Get full range of data
var SRange = ss.getDataRange();
//get A1 notation identifying the range
var A1Range = SRange.getA1Notation();
//get the data values in range
var SData = SRange.getValues();
var tss = SpreadsheetApp.openById('1ss......'); // tss = target spreadsheet
var ts = tss.getSheetByName('CalDatabase'); // ts = target sheet
ts.getRange(A1Range).setValues(SData);
}
上面的引号工作正常,但始终复制到同一行,但是我希望它将数据复制到下面的新空白行中。
答案 0 :(得分:0)
尝试一下-
function CopyDataToNewFile() {
var sss = SpreadsheetApp.openById('1vHc........'); // sss = source spreadsheet
var ss = sss.getSheetByName('Database'); // ss = source sheet
var SData = ss.getDataRange().getValues();
var tss = SpreadsheetApp.openById('1ss......'); // tss = target spreadsheet
var ts = tss.getSheetByName('CalDatabase'); // ts = target sheet
ts.getRange(ts.getLastRow()+1,1,SData.length,SData[0].length).setValues(SData);
}