Google表格脚本-将数据范围从一张工作表复制到另一张工作表-整个范围都无法复制 [英] Google Sheets Script - Copying data range from one sheet to another - whole range not copying
本文介绍了Google表格脚本-将数据范围从一张工作表复制到另一张工作表-整个范围都无法复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个菜鸟,正在学习atm.我正在使用以下脚本在同一Google电子表格中将数据从一张纸复制到另一张纸:
Bit of a rookie at this and learning atm. I am using the following script to copy data from one sheet to another in the same Google spreadsheet:
function recordHistory() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Cover");
var source = sheet.getRange("a1:c21");
var values = source.getValues();
var sheet2 = ss.getSheetByName("January 2020")
values [0] [0] = new Date();
sheet2.appendRow(values [0])
}
哪个可以很好地复制单行,但不能复制列出的整个范围(a1:c21).现在,我想问题出在第8行,但我不确定.
Which works fine to copy a single row but does not copy the entire range listed (a1:c21). Now I imagine the problem lies around Row 8 but I am not sure.
这是我用来尝试此工作的电子表格的链接:
Here is the link to the spreadsheet I am using for trying this out:
推荐答案
function recordHistory() {
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName("Cover");
var source = sheet.getRange("a1:c21");
var values = source.getValues();
var sheet2 = ss.getSheetByName("January 2020")
values [0][0] = new Date();
sheet2.getRange(sheet2.getLastRow()+1,1,values.length,values[0].length).setValues(values);
}
这篇关于Google表格脚本-将数据范围从一张工作表复制到另一张工作表-整个范围都无法复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文