Google Apps脚本:复制电子表格速度很慢 [英] Google Apps Script : copying spreadsheet is very slow
问题描述
我有一个Web应用程序,脚本连接到电子表格。在脚本中,我从电子表格中查找文件的ssid,打开该文件,然后复制并重命名它。相关行如下所示:
var copy = SpreadsheetApp.openById(ssid).copy(newName);
该行持续执行大约需要5秒钟。有没有其他人经历过这种延迟?有什么办法可以优化这个任务吗?谢谢你,嘉莉
您可能想尝试使用 DriveApp
:
$ b
函数copyFile(){
var theFile = DriveApp.getFileById('Your File ID');
theFile.makeCopy();
};
打开文件复制它没有意义。 I have a Web App where the script is connected to a Spreadsheet. In the script, I look up a file's ssid from the spreadsheet, I open that file, and then I copy and rename it. The relevant line looks like this:
var copy = SpreadsheetApp.openById(ssid).copy(newName);
That line consistently takes about 5 seconds to execute. Has anyone else experienced this delay? Is there any way to optimize this task? Thank you, Carrie
You might want to try using DriveApp
instead:
function copyFile() {
var theFile = DriveApp.getFileById('Your File ID');
theFile.makeCopy();
};
Google Documentation - Drive App
You can also designate a different folder to copy the file to. There's no point opening the file to copy it.
这篇关于Google Apps脚本:复制电子表格速度很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!