情况:
我有一个包含10个工作表和15个用户登录并修改它的电子表格 . 我想从其他电子表格中复制6张纸 .
需要的脚本功能:
该脚本应该是复制表到另一个特定的电子表格 .
1)Source = XXXXXX我想从Source只复制sheet1,2,3,4,5,6,7,8到目标 . 目标= YYYYY
注意:目标已经有了表1,2,3,4,5,6,7,8 . 我需要更新目标电子表格,因为我使用它来制作报告 . 我不能使用这个报告,因为这份报告是保密的 .
2)脚本需要从目标运行 .
问题:
我阅读了很多论坛,但是有人提供了一个关于“如何将表格复制到其他表”的通用脚本 . 所有这些脚本都非常复杂,我是新手 .
测试用例:
N / A
我认为是从一个电子表格到另一个电子表格的简单的工作表副本,但我需要在oneshot中执行此操作实际上我手动执行此操作但是我已经发出系统将工作表名称更改为XXXXX的副本但我的报告配置为使用特定的名字,这就是我需要的原因 . 我认为这个脚本会对很多人有所帮助 .
提前致谢 .
编辑:14/06/2013
嗨,
请问你能帮助我调整这个脚本以提高工作效率 .
function UpdateData() {
var source = SpreadsheetApp.openById('YYYYYY');
var sheet8 = source.getSheets()[8];
var sheet7 = source.getSheets()[7];
var sheet6 = source.getSheets()[6];
var sheet5 = source.getSheets()[5];
var sheet4 = source.getSheets()[4];
var sheet3 = source.getSheets()[3];
var sheet2 = source.getSheets()[2];
var sheet1 = source.getSheets()[1];
var destination = SpreadsheetApp.openById('ZZZZZZ');
sheet8.copyTo(destination).setName('Sheet8');
sheet7.copyTo(destination).setName('Sheet7');
Utilities.sleep(100);
sheet6.copyTo(destination).setName('Sheet6');
sheet5.copyTo(destination).setName('Sheet5');
Utilities.sleep(100);
sheet4.copyTo(destination).setName('Shee4');
sheet3.copyTo(destination).setName('Shee3');
Utilities.sleep(100);
sheet2.copyTo(destination).setName('Shee2');
sheet1.copyTo(destination).setName('Shee1');
SpreadsheetApp.flush();
}
1 回答
只需查看文档:copyTo(spreadsheet),从描述中:
该方法重新编写复制的工作表,以便您可以重命名它:
我希望,你知道如何在JS中编写循环...