将工作簿 A 中的工作表 1 复制到工作簿 B 的工作表 1
我正在尝试将工作表从我所说的“主”工作簿复制到我的员工可以访问的工作簿,但我似乎无法复制它。
一旦我有了脚本,我就会将其设置为每天复制。这样我就可以编辑主文件,它基本上每天都会为我的员工“自动更新”。
function copyDoc() {
var sourceSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('General');
var targetSheet = SpreadsheetApp.openById('13ERWTQoXeGb0cIfgfr2ZTsImnwmtaVB5c-Zm9ZZ5o6g').getSheetByName('General');
sourceSheet.copyTo(targetSheet);
}
它只是告诉我有一个错误:
错误
异常:参数 (number,number,number,null) 与 SpreadsheetApp.Sheet.getRange 的方法签名不匹配。 copyDoc @测试 Copy.gs:11
我完全不知道我在做什么或应该做什么。本质上,我每天都需要将工作簿 A 中的工作表 1 到工作表 7 复制到工作簿 B 的工作表 1 到工作表 7 中。但这些工作表都已经在每个工作簿中并带有标题。
I'm trying to copy sheets from what I'm calling a "Master" workbook to a workbook that my staff has access to but I can't seem to get it to copy.
Once I have the script, I'm going to set it up to copy every day. That way I can edit the Master and it will essentially "auto update" for my staff every day.
function copyDoc() {
var sourceSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('General');
var targetSheet = SpreadsheetApp.openById('13ERWTQoXeGb0cIfgfr2ZTsImnwmtaVB5c-Zm9ZZ5o6g').getSheetByName('General');
sourceSheet.copyTo(targetSheet);
}
It just tells me there's an error:
Error
Exception: The parameters (number,number,number,null) don't match the method signature for SpreadsheetApp.Sheet.getRange.
copyDoc @ Test Copy.gs:11
I have absolutely no idea what I'm doing or what I should be doing. Essentially I need to copy Sheet 1 through 7 from Workbook A into Sheet 1 through 7 of Workbook B every single day. But the sheets are all already in each Workbook and titled.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
屏幕截图显示您的项目有 4 个文件。
具有您尝试执行的函数的文件位于文件
Copy Daily.gs
中。该文件只有 7 行。该错误不属于该文件(如下所述)。Test Copy.gs
是包含导致错误的语句的文件名。11
是Test Copy.gs
文件的行号。getRange
是有问题的方法,很可能发生错误,因为文件
Test Copy.gs
中引用的行位于全局中范围。全局范围内的语句,无论它们在哪个文件上,都会在执行调用的函数之前执行。可能的修复方法:
Test Copy.gs
文件//
另一种选择是删除
Test Copy.gs
文件。如果您有关于该文件的有价值的信息,请在删除它之前进行适当的备份。相关
The screenshot shows that your project has 4 files.
The file having the function that you are trying to execute is in file
Copy Daily.gs
. This file has only 7 lines. The error doesn't belong to that file (as explained below).Test Copy.gs
is the file name having the statement causing the error.11
is the line number of theTest Copy.gs
file.getRange
is the method having the problemIt's very likely that the error is occurring because the referred line from file
Test Copy.gs
is in the global scope. Statements in the global scope, no matter on which file they are, are executed before executing the function called.Possible fix:
Test Copy.gs
file//
at the beginning of line 11Another option is to delete the
Test Copy.gs
file. If you have valuable information on that file, before deleting it, make an appropriate backup.Related
我在 Reddit 上询问,结果成功了!
然后,我只需复制并粘贴它并更改工作表的名称,因为它适用于我在一份文档中拥有的所有工作表。
I asked on Reddit and this ended up working!
I then just copied and pasted it and changed the name of the sheets for it work across all of the sheets I have in one document.