简体   繁体   English

脚本可以编辑受保护的范围或工作表吗?

[英]Can a script edit a protected range or sheet?

I'm using a script to copy and paste some data with is filled by a couple of users without permission to edit only one line, the others ranges are protected from edit by these users. 我正在使用一个脚本来复制和粘贴一些数据,该数据由几个用户填充,而没有权限仅编辑一行,而其他范围则受到这些用户的保护。

The script copies the data from one sheet to another and both sheets are entirely protected, except by two editors who can edit anything. 该脚本将数据从一个工作表复制到另一个工作表,并且两个工作表均受到完全保护,只有两个可以编辑任何内容的编辑器才可以。 This same script is triggered on a time-based trigger when no one is working on this spreadsheet. 当没有人在此电子表格上工作时,将在基于时间的触发器上触发相同的脚本。

The question is: A script is able to edit a protected sheet or range? 问题是:脚本能够编辑受保护的工作表或范围吗?

Here is the code (just in case): 这是代码(以防万一):

function CopyDaily() {
  var ss = SpreadsheetApp.openById('1olKDp').getSheetByName('Produtos vendidos'); //Seleciona a planilha DE ONDE os dados devem ser copiados
  var sss= SpreadsheetApp.openById('1olKDp').getSheetByName('BD Produtos vendidos'); //Seleciona a planilha PARA ONDE os dados devem ser copiados
  var LastRow1 = SpreadsheetApp.openById('1olKDp').getSheetByName('BD Produtos vendidos').getLastRow() + 1;
  var LastRow2 = SpreadsheetApp.openById('1olKDp').getSheetByName('BD Produtos vendidos').getLastRow() + 6;
  Logger.log(ss.getName());
  ss.getRange('A2:S7').copyTo(sss.getRange('A' + LastRow1 + ':S' + LastRow2), {contentsOnly:true})
}

function addTrigger() {
  var everyDay = ScriptApp.newTrigger("CopyDaily")
  .timeBased() //Define o tipo da trigger: Baseada em hora.
  .everyDays(1) //Frequencia de dias: a cada 1 dia.
  .atHour(12) //Em qual hora: 1 am.
  .create(); //Cria a trigger baseada nos parametros acima.
}

That depends, yes, a script is able to edit a protected range, what matters is who runs the script. 是的,这取决于脚本能够编辑受保护的范围,重要的是谁来运行脚本。 The person (account) running the script must have edit permission on the protected range. 运行脚本的人(帐户)必须对受保护范围具有编辑权限。 If the account running the script does not have edit permission on the protected range then the code will throw an exception. 如果运行脚本的帐户对受保护范围没有编辑权限,则代码将引发异常。

暂无
暂无

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

相关问题 取消保护受保护工作表中的范围 - Unprotect a range in a Protected Sheet 如何允许用户通过脚本编辑受保护范围? - How to allow users to edit protected range through script? 如何使 Google Sheet 中的受保护范围可从 App Script 访问 javascript function - How to make a protected range in Google Sheet accessible for a javascript function from App Script 取消保护受保护的工作表,以便其他人可以运行脚本,然后再次保护工作表 - Unprotecting protected sheet so that others can run script and then protect the sheet again Google Sheets Apps脚本处于“编辑”状态时,从受保护范围中删除编辑器的速度非常慢/未完成 - Google Sheets Apps Script On Edit Remove Editors From Protected Range Very Slow / Not Completing 我可以在应用程序脚本谷歌表中按范围获取单元格名称吗 - Can I get name of cell by range in app script google sheet Google Sheet App Script 保护范围并允许基于电子邮件的编辑,但从编辑权限中排除少数列 - Google Sheet App Script Protect Range & Allow Editors Based on Email But Exclude Few Columns From Edit Rights 将数据表1复制到工作表2,以便您可以对两个表进行排序和编辑(Google Apps脚本?) - Copying Data Sheet1 to Sheet2 so you can sort & edit both sheets (google apps script?) 如果用户没有编辑表格的权限,Google脚本可以编辑单元格吗? - Can a google script edit a cell if the user does not have permission to edit the sheet? 在受保护范围内运行 Google App Script - Run Google App Script in a Protected Range
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM