使用Google电子表格脚本复制并粘贴 [英] copy and paste with google spreadsheet script
本文介绍了使用Google电子表格脚本复制并粘贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想修改以下所示的脚本,以便重新运行时不会覆盖现有数据,而是在其下写入行.
I would like to modify the script shown below, so that if re-run, it does not overwrite pre-existing data, but instead writes the rows under it.
(我使用的是Google电子表格)
(I use the google spreadsheet)
moveValuesOnly fonction () {
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("Sheet1 F1: H3 ');
source.copyTo (ss.getRange ("Feuil2 A1! '), {contentsOnly: true});
source.clear ();
}
推荐答案
此版本将在目标工作表中找到第一个空行,并复制源数据,以便从那里开始.
This version will find the first empty row in the destination sheet, and copy the source data so it starts there.
function moveValuesOnly () {
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("Sheet1!F1:H3");
var destSheet = ss.getSheetByName("Feuil2");
// Déterminer l'emplacement de la première ligne vide.
var destRange = destSheet.getRange(destSheet.getLastRow()+1,1);
source.copyTo (destRange, {contentsOnly: true});
source.clear ();
}
这篇关于使用Google电子表格脚本复制并粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文