如何获得删除 Google 表格中行的权限? [英] How do I get permission to delete rows in Google Sheets?

查看:17
本文介绍了如何获得删除 Google 表格中行的权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这个脚本:

function enterData(data) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet()
  var row = sheet.getActiveRange().getRow()
  if(data == "" || data == "-"){
    sheet.deleteRow(row)
  } else {
    return data;
  }
}

如果某个单元格为空,我试图删除一行,它似乎工作得很好,除了它不允许实际删除该行.

I am attempting to delete a row if a certain cell is empty, and it seems to work just fine except for the fact that it won't allow to actually delete the row.

我使用 =enterData(whatever_cell_i_choose) 在一个单元格中运行我的函数.我读到自定义函数的功能有限,但我似乎找不到任何其他方法来做到这一点.

I run my function through a cell by using =enterData(whatever_cell_i_choose). I've read that custom functions have limits to what they can do, but I can't seem to find any other way to do it.

推荐答案

错误图像表明您将代码用作 自定义函数.它们只允许返回单个值或值数组.他们不允许执行任何需要授权的更改操作,例如删除行,因此,您的自定义函数无法获得删除行的权限.而是使用菜单或可安装的触发器来运行它.

The error images shows that you are using your code as a custom function. They are only allowed to return a single value or an array of values. They are not allowed to do any action that change that requires authorization like deleting a row, so, it's not possible to get permission to delete a row for your custom function. Instead use menu, or an installable trigger to run it.

这篇关于如何获得删除 Google 表格中行的权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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