表单提交后动态更新单元格 [英] Dynamically update cells after form submission

查看:71
本文介绍了表单提交后动态更新单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图根据代码创建一个用户列表,简单地说我们有一个系统,我们学校的每个成员都有一个分配的代码,通过这个代码,我可以通过创建一些正则表达式来获取他们的姓名和电子邮件在我们的网站上(基本上是数据挖掘)。

这个想法是只输入这个用户代码(比如0123456),一个脚本会从网站获取数据并填写相邻的列值。该脚本必须在表单子触发器上的上运行,因此只在需要时更新。



我成功实现了数据收集系统,但是我在填充相邻的单元时挣扎着。

  //当提交表单时调用这个函数
函数onNewEntry(e)
{
//获取代码(单元格0是时间戳记)
userCode = e.values [1];

//添加值并返回
返回e.values.concat([name,e-mail]);
}

我希望脚本能够将C和D列中的单元格改为name 和电子邮件,但没有任何反应。任何人都可以提出建议吗?

解决方案

这个函数在Form提交时触发,会在C列和D列写入数据。 b
$ b

(我用xx和yy来说明)

 函数myFunction(e){ 

var sh = SpreadsheetApp.getActiveSpreadsheet()。getSheets()[0];

var last = sh.getLastRow()

sh.getRange(last,3,1,2).setValues([['xx','yy']] )
}


I'm trying to make a user list based on a code, simply put we have a system where every member of our school has an assigned code, with this code I can get their name and e-mail by making some regexes on our website (basically data mining).

The idea is to enter only this user code (let's say 0123456) and a script will get the data from the website and fill adjacent column values. The script must run on the on form subit trigger, so it's updated only when needed.

I've successfully implemented the data gathering system, but I'm struggling in the filling of the adjacent cells.

// this function is called when form is submitted
function onNewEntry(e)
{
  // get the code (cell 0 is the timestamp)
  userCode = e.values[1];

  // add values and return
  return e.values.concat(["name", "e-mail"]);
}

I expected the script to change the cells in columns C and D with "name" and "e-mail", but nothing happens. Can anybody advise?

解决方案

This function when triggered by on Form submit will write data in column C and D

(I used xx and yy just to illustrate)

function myFunction(e) {

var sh = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];

var last = sh.getLastRow()

sh.getRange(last,3,1,2).setValues([['xx','yy']])
}

这篇关于表单提交后动态更新单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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