简体   繁体   English

在后台运行Google Apps脚本

[英]Run Google Apps Script in background

I have a spreadsheet where I paste data in one sheet then run an Apps Script that parses, sorts, and send emails with attachments. 我有一个电子表格,在其中将数据粘贴到一张工作表中,然后运行一个Apps脚本来解析,排序和发送带有附件的电子邮件。 I have about 300 lines of code and currently it takes about 5-10 minutes to run if I leave the sheet open. 我有大约300行代码,如果我不打开工作表,目前大约需要5-10分钟才能运行。 When I try to move to other tabs in google,or try to compose a message in gmail and what not, I get the error message "unable to load file" and I have to reload, stopping the script. 当我尝试移至google中的其他标签,或尝试在gmail中撰写一条消息时,我收到错误消息“无法加载文件”,必须重新加载,停止脚本。

My spreadsheet has about 15 sheets, each with a filter formula in each. 我的电子表格大约有15张纸,每张纸都有一个过滤器公式。 There are tons of get and set range values. 有大量的获取和设置范围值。

Is there any easy way to compose a script and the sheet so I can paste the data into it, then close the sheet and still have the script run in the background? 有什么简单的方法可以编写脚本和工作表,以便我可以将数据粘贴到其中,然后关闭工作表并仍然在后台运行脚本?

I'm not sure what is causing the "unable load file" error message as there isn't code include in the question but it's worth to note that some Spreadsheet Services methods take data from the active sheet or from the active range. 我不确定是什么原因导致了“无法加载文件”错误消息,因为问题中没有包含代码,但是值得注意的是,某些Spreadsheet Services方法从活动工作表或活动范围中获取数据。 If your script uses these methods and you click on a different sheet/range that provide the data required by the script that could make that the script produce unexpected results. 如果您的脚本使用这些方法,并且您单击了不同的工作表/范围,则该表/范围提供了脚本所需的数据,这可能会使脚本产生意外的结果。

By the other side, Google Apps Script run on the Google's Servers but formula recalculation occurs on the user environment if your device doesn't have enough resources to handle your spreadsheet recalculation could the the cause of the problem. 另一方面,Google Apps脚本在Google的服务器上运行,但是如果您的设备没有足够的资源来处理电子表格的重新计算,则在用户环境中会发生公式重新计算,这可能是导致问题的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM