Google Apps Script : copying spreadsheet is very s

2019-07-11 05:09发布

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

1条回答
够拽才男人
2楼-- · 2019-07-11 05:42

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.

查看更多
登录 后发表回答