Explanation:
You can use openById(id) to access a different spreadsheet file by its id. As the documentation states:
For example, the spreadsheet ID in the URL
https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 is
"abc1234567".
and assuming that the target spreadsheet has a sheet named "Output"
then the following code will work. Otherwise, change it to the name of the target sheet.
Solution:
function ScriptBS() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ts = SpreadsheetApp.openById(id); // put here the id of the target spreadsheet file
var inputS = ss.getSheetByName("Input");
var outputS = ts.getSheetByName("Output"); // get sheet Output of the target spreadsheet file
var inputRng = inputS.getRange("A2:I2");
var values = inputRng.getValues();
inputRng.clearContent(); // clear input range
outputS.getRange(outputS.getLastRow()+1, 1, 1, values[0].length).setValues(values);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…