简体   繁体   English

Google Forms 中的可填写表格,将数据记录在特定的 Google 表格中

[英]A fillable table in Google Forms that records data in a specific Google Sheet

I'm trying to create a table with editable cells in a google form that lets people enter their recorded measurements.我正在尝试在谷歌表单中创建一个包含可编辑单元格的表格,让人们输入他们记录的测量值。 Then compile that information into a Google Sheet by specified columns.然后按指定的列将该信息编译到 Google 表格中。

I have tried the Awesome table but I cannot seem to get the script to work.我已经尝试过 Awesome 表,但我似乎无法让脚本正常工作。

Broken Down, I need the Script to be able to:分解,我需要脚本能够:

  • import a table into google forms将表导入谷歌 forms
  • edit the number of columns and rows编辑列数和行数
  • allow multiple people to record their measurements individually允许多人分别记录他们的测量结果
  • Compile the recorded data into a sheet by column.将记录的数据逐列编译成一张表。

This may be a simple question that I am overthinking.这可能是一个我想多了的简单问题。 But I am trying to avoid multiple questions on the same form, and think a table would be way easier.但我试图避免在同一张表格上出现多个问题,并认为一张表格会更容易。

As talked in the comments, since there is no table item in FormApp , this solution consists in sending a Sheet with a predefined table for users to fill.正如评论中所说,由于FormApp中没有表格项,因此该解决方案包括发送带有预定义表格的表格供用户填写。 They will press a button and send the data to a master sheet.他们将按下一个按钮并将数据发送到主表。

CODE代码

function sendData() {           

  //Gets the sheet is being edited
  var sprsheet = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = sprsheet.getActiveSheet();

  //Gets the data introduced by the user
  var range = sheet.getRange("A2:L2");
  var values = range.getValues();

  //Gets the target sheet
  var mainsprsheet = SpreadsheetApp.openById("main sheet id");
  var targetSheet = mainsprsheet.getActiveSheet();

  //Adds a new row to the target sheet with the collected data
  targetSheet.appendRow(values);

  //Clear the cells (optional)
  range.clearContent();
}

BUTTON按钮

To create the "submit" button to run the function above:要创建“提交”按钮以运行上面的 function:

  1. Go to Insert > Drawing Go 插入 > 绘图
  2. Design your own button设计自己的按钮
  3. Save and close保存并关闭
  4. Click on the button and then on the 3 dots at the right-top.单击按钮,然后单击右上角的 3 个点。
  5. Click on "Assign script" and write sendData单击“分配脚本”并编写sendData

You can place the button anywhere and resize it.您可以将按钮放置在任何位置并调整其大小。

NOTES笔记

  • You might want to send copies of this sheet to the different users to avoid sharing of sensitive data.您可能希望将此工作表的副本发送给不同的用户,以避免共享敏感数据。

REFERENCES参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM