简体   繁体   English

工作表受到保护时,Google App Script 删除行不起作用

[英]Google App Script delete rows not working while sheet is protected

I am having a google apps script to clear the googlesheet empty rows, it was working previously but recently encountered issue as mentioned.我有一个谷歌应用程序脚本来清除 googlesheet 空行,它以前可以工作,但最近遇到了前面提到的问题。

error message错误信息

Exception: Service Spreadsheets failed while accessing document with id XXXX.例外:服务电子表格在访问 ID 为 XXXX 的文档时失败。

Deletes all empty rows:删除所有空行:

function delMTs() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getActiveSheet();
  const vs = sh.getDataRange().getValues();
  let d = 0;
  vs.forEach((r,i)=>{
    if(r.join()=='') {
      sh.deleteRow(i+1-d++);
    }
  });
}

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

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