问题描述
我正在尝试修改一些脚本以通过电子邮件将Google表单的结果发送给自己.该脚本以其基本形式运行,但是我似乎无法从单元格中检索值并将其复制到主题字段中.
I am trying to modify a little script to email myself the results of a Google Form.The script is working in its basic form, but I can't seem to be able to retrieve the value from a cell and copy it in the subject field.
这是我正在尝试的:
var lastRow = SpreadsheetApp.getActiveSheet().getMaxRows();
var title = SpreadsheetApp.getActiveSheet().getRange(lastRow, 2).getValues();
var subject = "Todo List: " + title;
当我这样做时,脚本停止工作了:)知道为什么吗?谢谢
The script stops working though, when I do that :)Any idea why? Thanks
推荐答案
getValues()
将返回一个二维Javascript数组(所以我认为getValues()[0][0]
应该可以);但是,由于您希望从单个单元格中检索单个值,因此最好使用getValue().
getValues()
will return a 2-dimensional Javascript array (so I think getValues()[0][0]
should work); but as you are wanting to retrieve a single value from a single cell, you may as well just use getValue().
var title = SpreadsheetApp.getActiveSheet().getRange(lastRow, 2).getValue();
这篇关于在Google Spreadsheet脚本中获取特定的单元格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!