Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.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
Google apps script 获取单元格和settitle';单元格';_Google Apps Script_Google Sheets_Google Forms - Fatal编程技术网

Google apps script 获取单元格和settitle';单元格';

Google apps script 获取单元格和settitle';单元格';,google-apps-script,google-sheets,google-forms,Google Apps Script,Google Sheets,Google Forms,我得到了“A2单元”,我想把片名改成“A2” 如何做?请帮帮我 function MyFunction() { var sheet = SpreadsheetApp.getActiveSheet(); var value1 = sheet.getRange('A2').getValue(); var form = FormApp.openByUrl("my form url"); var item25 = form.addMultipleChoiceItem(

我得到了“A2单元”,我想把片名改成“A2” 如何做?请帮帮我

function MyFunction() {
    var sheet = SpreadsheetApp.getActiveSheet();

    var value1 = sheet.getRange('A2').getValue();

    var form = FormApp.openByUrl("my form url");
    var item25 = form.addMultipleChoiceItem();
    item25.setTitle('A2')
    item25.setChoices([
        item25.createChoice('B2'),
        item25.createChoice('B2')
    ])
    // ....
}
执行
item25.setTitle(value1)
而不是
item25.setTitle('A2')

否则,您不会使用变量
value1

如果您查看一下文档,就会返回一个对象(在本例中,我假设是一个字符串)并需要一个字符串,因此可以在setTitle中使用value1


我建议您查看一些javascript文档,如和。

您的代码已经将标题设置为字符串文字“A2”。您的意思是想将新添加项的标题设置为电子表格单元格A2的值吗?是的,我想添加电子表格单元格A2的值