使用Google App脚本更改Google表格共享设置 [英] Change Google Sheet sharing settings using Google App Script

查看:180
本文介绍了使用Google App脚本更改Google表格共享设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,该脚本在运行时会创建许多Google工作表(通过复制母版,然后向每个工作表添加特定数据),并将每个工作表放入不同的文件夹中.每个文件夹都与不同的人(编辑者)共享,因此不同的人可以看到每个工作表.

I have a script that creates a number of Google sheets (by duplicating a master and then adding specific data to each sheet) when it runs and puts each sheet into a different folder. Each folder is shared with different people (editors) so different people can see each sheet.

对于创建的每个工作表,我都希望停止每个编辑器都可以与其他人共享文件.

For each sheet that is created I want to stop each editor being able to share the file with others.

我已经找到了如何使用file.isShareableByEditors()来检查此权限,但是我看不到如何更改它.

I have found how to check this permission using file.isShareableByEditors() but I cannot see how to change it.

我正在复制的主文件确实启用了此设置,但是在复制权限时不会保留.

The master file that I am duplicating does have this setting enabled however when duplicating the permission is not carried over.

推荐答案

方法 setShareableByEditors 防止编辑者共享文件:

The method setShareableByEditors prevents file sharing by editors:

const stopEditorsFromSharingFile_ = file => file.setShareableByEditors(false)

这篇关于使用Google App脚本更改Google表格共享设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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