TypeError:无法调用方法"getActiveSheet";的null [英] TypeError: Cannot call method "getActiveSheet" of null

查看:277
本文介绍了TypeError:无法调用方法"getActiveSheet";的null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TypeError:无法调用方法"getActiveSheet"为空

SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("D2").setValue(99)

请查看屏幕截图所有我想在给定范围内的表中设置该值.

Please look into the screenshot All i want to set the value into the sheet with given range.

Code.gs

sheat01

这是代码

function myF() {
var app = SpreadsheetApp;
var g_as = app.getActiveSpreadsheet();
var as = g_as.getActiveSheet();
as.getRange("D2").setValue(99);

}

推荐答案

我做到了,而且有效.记录仪返回单词范围".我没想到它会回来的任何东西.

I did this and it works. The Logger comes back with the word Range. I had no expectation that it would come back with anything.

function myF()
{
   SpreadsheetApp.getActive().getActiveSheet().getRange('D2').setValue(99);
}

每次将O19更改为99.

It changes O19 to 99 every time.

每当我开始遇到奇怪的事情时,我都会关闭浏览器,然后重新启动,通常就可以解决问题.

Whenever I start getting weird stuff going on I shut down the browser and come back up and that generally does the trick.

这篇关于TypeError:无法调用方法"getActiveSheet";的null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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