简体   繁体   English

通过脚本授予编辑权限(谷歌应用脚本)

[英]give edit permission by script (google apps script)

I have google spreadsheet with script and sidebar (html input fields).我有带有脚本和侧边栏(html 输入字段)的谷歌电子表格。 I will share this spreadsheet with my colleagues.我将与我的同事分享这个电子表格。 and my colleagues will make a copy of my spreadsheet for personal use.我的同事会复制我的电子表格供个人使用。

this is problem这是问题

  • when I edit my script, I want to edit my colleagues's spreadsheet script that copies of my spreadsheet.当我编辑我的脚本时,我想编辑我的同事的电子表格脚本,该脚本是我的电子表格的副本。

  • for this, Here is my idea.为此,这是我的想法。

    1. when my colleague run specific button(scirpt) on sheet first of all before use sheet, automatically I get edit permission of that spreadsheet.当我的同事在使用工作表之前首先在工作表上运行特定按钮(脚本)时,我会自动获得该电子表格的编辑权限。 and then I go to my colleagues's spreadsheet script and edit it.然后我 go 到我同事的电子表格脚本并编辑它。 Is their any script for this?他们有任何脚本吗?
    1. one script file and run multiple spreadsheets.一个脚本文件并运行多个电子表格。 my script is for input some data specific sheet and cell by html input form on sidebar.我的脚本用于通过侧边栏上的 html 输入表单输入一些数据特定表和单元格。 There are several input forms and specific sheet names and cell addresses are specified to set values.有几个输入 forms 并指定特定的工作表名称和单元格地址来设置值。 Is their any way for 2?他们对2有什么办法吗? I've tried publish add-on.我试过发布插件。 but didn't work well.但效果不佳。 plz give me some idea.请给我一些想法。

For the first part, you can just add the lines;对于第一部分,您可以只添加行;

var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.addEditor('----@-------');

To directly create / edit script files you'll have to use the App Script API要直接创建/编辑脚本文件,您必须使用 App Script API

App Script API应用程序脚本 API

For the second part, you can write the scripts in a stand-alone file and use the script library in the spreadsheet.对于第二部分,您可以在独立文件中编写脚本并使用电子表格中的脚本库。 Leaving the script in development mode will always use the current code in the script file.将脚本留在开发模式将始终使用脚本文件中的当前代码。

Apps-script libraries 应用程序脚本库

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

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