共享包含工作组脚本的Google Spreadsheet,以便他们可以使用它,但不能对其进行修改 [英] Sharing a Google Spreadsheet containing a script with a workgroup so they can use it, but not modify it

查看:257
本文介绍了共享包含工作组脚本的Google Spreadsheet,以便他们可以使用它,但不能对其进行修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个Google Spreadsheet脚本,用于从用户提供的CSV文件中读取数据,用数据填充表单,用不同的名称制作电子表格的副本,并提供用户点击以查看新的电子表格。在创建新副本后,原始电子表格将被清除用户数据并恢复到其原始状态,以便其他用户可以使用它。



我想与此人共享此电子表格工作组(数百个用户),但我不希望他们能够修改工作表或脚本。如果我分享它,只读的脚本将不会运行,但为了让脚本运行,我必须允许用户编辑功能,这是一件坏事。



我曾愚蠢地试图找到一个方向,但我仍然在荒野中徘徊。



你们中的任何一个人能否指出我的方向是正确的?如果我需要更具体或提供更多信息,我会很乐意这样做。



谢谢,

拉里



PS其他问题:

o电子表格中的应用程序脚本是否可以使新副本处于活动状态并关闭原始共享电子表格?



o用户可以成为新副本的所有者吗?

解决方案

可以选择将不想修改的代码放入独立应用程序脚本文件,然后将该代码作为绑定到工作表的脚本中的库使用。您可以将独立应用程序脚本的权限设置为仅查看。这将阻止人们改变它。当您与用户共享Apps脚本文件时,他们会收到电子邮件通知。因此,他们将拥有该文件的网址,并可以查看该网址,但无法对其进行编辑。 (如果您将其设置为仅查看)



因此,您将同时使用电子表格文件和Apps脚本文件。两个文件,并仅在Apps脚本文件中将共享设置为VIEW。您仍然可以让人员编辑访问电子表格。



您需要完成将函数提供给电子表格的过程。这被称为库,但创建该文件时不要太在意这个名称。




  • 创建独立应用程序脚本

  • 创建您想要共享的功能。





  • 与想要授予访问权限的用户共享Apps脚本文件,但仅授予他们对文件的VIEW权限。不要编辑。

  • 将项目密钥交给用户(在这种情况下就是你),让他们添加库,或者如果你有权访问电子表格,自己添加密钥。所以,就你而言,你不会与任何人共享项目密钥。您不需要。

  • 在绑定到电子表格的脚本文件中,单击资源菜单和LIBRARIES菜单项。

  • 输入项目密钥






  • 单击选择按钮,并打开库。确保将库标识符设置为要使用的关键字。

  • 转到代码编辑器,创建函数,然后键入库标识符。

  • 所有可从库中获得的函数都会显示出来



Google文档 - 访问图书馆

,创建一个库只不过是在独立的Apps脚本文件中的Apps脚本中编写代码。如果你已经这样做了,那么你需要分享的是项目密钥。当资源库打开时,库的用户将不会看到所有可用库的列表。你需要钥匙。


I have written a Google Spreadsheet script which reads data from a user provided CSV file, populates a sheet with the data, makes a copy of the spreadsheet with a different name, and provides a link for the user to click to see the new spreadsheet. After making the new copy, the original spreadsheet is then cleared of user data and restored to its original state so other users can use it.

I want to share this spreadsheet with the workgroup (several hundred users), but I don't want them to be able to modify either the sheet or the script. If I share it read-only the script won't run, but to get the script to run I have to allow users edit capability and that is a bad thing.

I have googled myself silly trying to find a direction in which to go, but I am still wandering in the wilderness.

Can any of you point me in the right direction? If I need to be more specific or provide more information I will be glad to do so.

Thanks,

Larry

P.S. Other questions of note:

o Is it possible for a app-script in a spreadsheet to make the new copy active and 'close' the original shared spreadsheet?

o Can the user be made the owner of the new copy?

解决方案

There is the option to put the code that you don't want modified, into a Stand Alone Apps Script file, then use that code as a "Library" in your script bound to the sheet. You can set the permissions on the Stand Alone Apps Script to VIEW only. That will keep people from changing it. When you share the Apps Script file with the users, they will get an email notification. So, they'll have the URL to the file, and can view it, but they can't edit it. (If you set it to VIEW only)

So, you'll be using both your spreadsheet file, and a Apps Script file. Two files, and setting the sharing to VIEW only on the Apps Script file. You can still give people EDIT access to the spreadsheet.

You'll need to go through a process of making the function available to your spreadsheet. This is called a "Library", but don't pay much attention to that name when creating the file.

  • Create a Stand Alone Apps Script
  • Create the function you want to share.
  • Get the Project Key --> FILE, PROJECT PROPERTIES

  • Share the Apps Script file with users you want to give access to, but only give them VIEW access to the file. NOT Edit.
  • Give the Project Key to the user, (In this case that's just you.) and have them add the library, or if you have access to the spreadsheet, you can probably add the key yourself. So, in your case, you will not be sharing the Project Key with anyone. You don't need to.
  • In the script file that is bound to the spreadsheet, click the RESOURCES menu, and the LIBRARIES menu item.
  • Enter the Project Key

  • Click SELECT button, and turn the library ON.
  • Make sure to set the library Identifier to a key word you'd like to use.
  • Go to the code editor, create a function, and type the Library Identifier.
  • All the functions that are available from the Library will show up

Google Documentation - Gaining Access to a Library

Keep in mind, that creating a library is nothing more than writing code in an Apps Script in a stand alone Apps Script file. If you've done that, then all you need to share is the Project Key. The user of the Library won't see a list of all the available Libraries when Resources, Libraries is opened. You need the Key.

这篇关于共享包含工作组脚本的Google Spreadsheet,以便他们可以使用它,但不能对其进行修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆