我如何获得删除Google表格中的行的权限? [英] How do I get permission to delete rows in Google Sheets?
问题描述
函数enterData(data){
var sheet = SpreadsheetApp.getActiveSpreadsheet( )
var row = sheet.getActiveRange()。getRow()
if(data ==|| data == - ){
sheet.deleteRow(row)
} else {
返回数据;
$ b我试图删除一行,如果某个单元格是空的,它看起来工作得很好,除非它不允许实际删除该行。
我通过使用 = enterData(whatever_cell_i_choose)
来运行我的函数。我已经读过,自定义函数对他们可以做的事情有限制,但我似乎无法找到任何其他方式来做到这一点。
div> 错误图片显示您将自己的代码用作自定义功能。它们只允许返回一个值或一组值。他们不允许执行任何需要授权的更改操作,如删除行,因此,无法获得为自定义函数删除行的权限。而是使用菜单或可安装的触发器来运行它。
I am using this script:
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.
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屋!