如何在Google文档中复制行范围? [英] How to copy row ranges in Google docs?
问题描述
我有一个电子表格,例如Google文档上的excel.我同时使用Mozilla Firefox和Google Chrome浏览器,无论哪种方法都可以.我几乎所有的列都有下拉列表验证(您知道,每个单元格都有一个下拉列表可供选择,我希望我已经明确了).第一次创建电子表格时,我对它们进行了排列,并对我创建的范围中的所有列进行了验证.我的问题是,每当我添加新行时,该行都没有任何验证,所有验证都消失了.旧行仍然具有验证.
I have a Spreadsheet, like excel on Google Docs. I am using both Mozilla Firefox and Google Chrome, whichever works. Almost all my columns have dropdown list validation(you know, each cell has a dropdown list to select, I hope I made it clear). I arranged them when I first created the spreadsheet, gave all the columns validation from ranges I created. My problem is, whenever I add a new row, that row doesn't have any validations, all of them are gone. The old rows still have the validations.
因此,每次添加新行时,我都会一次设置一次验证.这真令人沮丧.有人在网上问过同样的问题,但没有人回答.
So then, I set the validations every time I add a new row, one by one. This is frustrating. Some people also had the same problem, asked online, but no one answered.
当我复制带有验证的空行并将其粘贴到新行时,它可以正常工作.所以,我的意思是,您能帮我写一个脚本吗?喜欢在执行脚本时复制5行吗?
When I copy an empty row with validations and paste it on the new row, it works fine. So, what I am saying is, can you help me write a script for it? Like copying 5 rows when I execute the script?
我正在尝试学习脚本,但到目前为止我什么也没做.我认为
I am trying to study the scripts but I did nothing nothing so far. I think
var actSc = SpreadsheetApp.getActiveSpreadsheet();
var range = actSc.getRange("A1:B1");
所有这些都是我从示例中获得的.我是认真的.我什么都没有如果这复制了一个单元格的范围,那么我想我应该对我所有的列都这样做.但是,如何将它们放在新行中?是否有类似setRange的东西?我真的可以使用一些帮助.这让我发疯,而我真的没有得到这个脚本.
This all I got from the examples I saw. I mean it. I got nothing. If this copies the ranges of one cell, then I guess I should do it for all my columns. But how do I put them in the new row? Is there something like setRange? I could really use some help. This is driving me crazy and I really don't get this script thing.
我所指的范围是我具有"STATES"之类的范围,并且包括"NY,LA,CA"等.此NY,LA,CA填充了该STATES列的单元格中的下拉列表.我希望这个getRange意味着这个范围.
What I mean by range is that I have ranges like "STATES" and it includes "NY,LA,CA" etc. This NY,LA,CA fills the dropdown list in the cells of that STATES column. I hope this getRange means this range.
对不起,我的英语.
推荐答案
var sheetToUpdate = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheetToUpdate.insertRowAfter(sheetToUpdate.getLastRow());
var rangeToUpdate = sheetToUpdate.getRange(sheetToUpdate.getLastRow()+1,1,1,sheetToUpdate.getMaxColumns());
sheetToUpdate.getRange(sheetToUpdate.getLastRow(),1,1,sheetToUpdate.getMaxColumns()).copyTo(rangeToUpdate, {formatOnly:true});
这篇关于如何在Google文档中复制行范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!