[英]ClearRange automatically
I want to clear a specific range of my Google Sheet twice a day by triggering this function. 我想通过触发该功能每天两次清除特定范围的Google表格。
My script is as follows: 我的脚本如下:
function clearRange() {
var sheet = SpreadsheetApp.getActive().getSheetByName('test');
sheet.getRange('inventaire!B3:E8').clearContent();
}
But I get 但是我明白了
TypeError: Cannot call method "getSheetByName" of null.
TypeError:无法调用null的方法“ getSheetByName”。 (line 3, file "Code")
(第3行,文件“代码”)
I don't know why I receive this error. 我不知道为什么会收到此错误。
I would suggest you pass as parameter the name of the sheet where belongs the range in this case inventaire
not test
, by the way it appears your app is not linked to a spreadsheet as getActive
returns null
. 我建议您将表的名称作为参数传递给表名,在该表中该表属于该范围(在这种情况下,
inventaire
不进行test
,这样看来您的应用程序未链接到电子表格,因为getActive
返回null
。 Try to make sure your script is linked to your spreadsheet try also the getActiveSpreadsheet()
method then write. 尝试确保脚本已链接到电子表格,也尝试使用
getActiveSpreadsheet()
方法,然后编写。
function clearRange() {
var sheet = SpreadsheetApp.getActive().getSheetByName('inventaire');
sheet.getRange('B3:E8').clearContent();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.