简体   繁体   English

将Google表格菜单与Google Apps脚本一起使用

[英]Using Google Sheets Menu with Google Apps Script

I am new to Google Apps Script and looking for some insight into a feature I would like to implement. 我是Google Apps脚本的新手,正在寻找我想实现的功能的一些见解。

I am using the Google Analytics add-on inside of Google sheets to report on our site. 我正在使用Google表格中的Google Analytics(分析)插件在我们的网站上进行报告。 I have already set up a script to send out daily reports, but currently still have to run the reports manually using the add-on. 我已经设置了一个脚本来发送每日报告,但是目前仍然必须使用附加组件手动运行报告。 Is there a way I can access the add-on menu using Google Apps Script? 有什么方法可以使用Google Apps脚本访问附加菜单吗?

I'd like to add the functionality of clicking 'Run Reports' in the GA add-on menu before my daily email script. 我想在我的每日电子邮件脚本之前添加在GA附加菜单中单击“运行报告”的功能。 Any help would be greatly appreciated. 任何帮助将不胜感激。 Thanks! 谢谢!

I think what you mean is you're inside a sheet, and you want to be able to press Add-On->Add-on Name to run the report. 认为您的意思是您位于工作表中,并且希望能够按Add-On-> Add-on Name来运行报告。

You're not able to do this unless your script is a published Add-on available on the add on store for anyone to download. 除非您的脚本是发布的附加组件,否则您将无法执行此操作,该附加组件可在附加商店中找到,任何人都可以下载。 Given the restrictions Google currently has in place for that , it's unlikely you'll want to do that. 考虑到Google目前对此的限制 ,您不太可能想要这样做。

Instead, you want to create a custom menu. 而是要创建一个自定义菜单。 An example found here . 这里有一个例子。 I'm not going to bother copy/pasting their sample, as I'd be leaving it as is. 我不会打扰/粘贴他们的样本,因为我会原样保留它。

From the sounds of it though, you might prefer to create a time based trigger. 从声音上看,您可能更喜欢创建一个基于时间的触发器。 The simplest way to do this is open your script, press 'Resources' -> Current projects triggers -> 'Click here to add one now'. 最简单的方法是打开脚本,按“资源”->“当前项目触发器”->““单击此处立即添加””。 This will allow you to set a time based trigger to run every day for example. 例如,这将允许您设置基于时间的触发器以每天运行。

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

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