Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我无法从单元格b2获取我输入的值_Javascript_Google Apps Script_Google Sheets - Fatal编程技术网

Javascript 我无法从单元格b2获取我输入的值

Javascript 我无法从单元格b2获取我输入的值,javascript,google-apps-script,google-sheets,Javascript,Google Apps Script,Google Sheets,谷歌脚本范围在手机上无法正常工作,我无法从b2单元获取输入的值,a10的值始终为“范围” 答复: 您需要使用getValue()从单元格B2获取值,而不是setValue() 代码修复: 您需要更改: var name=ss.getRange('b2').setValue(); 致: var name=ss.getRange('b2').getValue(); 我希望这对你有帮助 参考资料: 欢迎来到StackOverflow。请确保在代码块中编写代码,以便我们更容易阅读和理解。要获取

谷歌脚本范围在手机上无法正常工作,我无法从b2单元获取输入的值,a10的值始终为“范围”

答复: 您需要使用
getValue()
从单元格B2获取值,而不是
setValue()

代码修复: 您需要更改:

var name=ss.getRange('b2').setValue();
致:

var name=ss.getRange('b2').getValue();
我希望这对你有帮助

参考资料:

欢迎来到StackOverflow。请确保在代码块中编写代码,以便我们更容易阅读和理解。要获取值,请使用getValue()。要设置,请使用set
function myfunction(){
    var ss = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1WfEJyQweOklYFfQbQKxXsDZy2pCElEwBq_DlhxfS9SM/edit?format=drivesdk").getActiveSheet();
    var name = ss.getRange('b2').setValue();
    var name2 = ss.getRange('a10').setValue(name);
}