How do I enter data into a new cell and use that data in my google script code?

时间:2018-02-01 18:37:54

标签: google-apps-script google-sheets

I want to start with being able to enter in cell A1 a name. Then that name appear into a document.

I would simply like to run a test so far where I end up with

e.range.setNote("Edited by: " + name);

Every time I run that tesI i get back "undefined" or "Range" never a name.

I know I'm bound to sheets and I am guessing I need the trigger to be onEdit or onChange

The data for final project is being added after form data is gathered on same sheet and on same rows. If that has anything to do with it.

1 个答案:

答案 0 :(得分:1)

输入数据并从单元格中获取数据。

var sh=SpreadsheetApp.getActiveSheet();
sh.getRange('A1').setValue('Name');
var name=sh.getRange('A1').getValue();