데이터 스크립트 복사가 더 이상 작동하지 않습니다.
Nov 25 2020
여기에서 찾은 Google 시트의 스크립트를 사용하고 있습니다.
Google 앱 스크립트에서 한 시트의 데이터를 다른 시트로 복사하고 행을 추가합니다.
var ss = SpreadsheetApp.getActiveSpreadsheet();
var copySheet = ss.getSheetByName("Copy");
var pasteSheet = ss.getSheetByName("Paste");
// get source range
var source = copySheet.getRange(2,2,12,2);
// get destination range
var destination = pasteSheet.getRange(pasteSheet.getLastRow()+1,2,12,2);
// copy values to destination range
source.copyTo(destination);
// clear source values
source.clearContent();
}
지금 실행할 때 오류가 발생합니다.
대상 범위의 좌표가 시트의 치수 밖에 있습니다.
전에는 나오지 않았던 것입니다. 왜이 일을하는지 아는 사람이 있습니까?
답변
1 Marios Nov 25 2020 at 18:31
발행물:
오류는 다음 줄에 있습니다.
var destination = pasteSheet.getRange(pasteSheet.getLastRow()+1,2,12,2);
pasteSheet.getLastRow()
시트의 맨 아래에있는 행 번호를 반환합니다. 그런 다음 12
행 범위 를 고려 하지만 콘텐츠가있는 마지막 행 뒤에 행 pasteSheet
이 없습니다 .12
해결책 :
에 행을 더 추가하십시오 pasteSheet
.

또는 insertRowsAfter 를 사용할 수 있습니다 .
pasteSheet.insertRowsAfter(pasteSheet.getLastRow(), 12)
코드 조각 :
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var copySheet = ss.getSheetByName("Copy");
var pasteSheet = ss.getSheetByName("Paste");
// get source range
var source = copySheet.getRange(2,2,12,2);
// insert rows to make sure you have enough space
pasteSheet.insertRowsAfter(pasteSheet.getLastRow(), 12)
// get destination range
var destination = pasteSheet.getRange(pasteSheet.getLastRow()+1,2,12,2);
// copy values to destination range
source.copyTo(destination);
// clear source values
source.clearContent();
}