简体   繁体   English

通过第三方链接将数据写入 Google 表格中的单元格

[英]Writing data to a cell in Google Sheets from a 3rd party link

How do I make a link that adds data to a Google Sheet?如何创建将数据添加到 Google 表格的链接?

I am working on a student calling system that allows the following: 1-Parents arrive at our school's entrance and show a QR Code 2-The QR Code is a link that specifies their child's name, year, etc. 3-That data is then sent to a Google Sheet that is being displayed in our assembly hall so the student knows their parent has arrived我正在开发一个学生呼叫系统,该系统允许以下操作: 1-家长到达我们学校的入口处并出示二维码 2-二维码是一个链接,其中指定了他们孩子的姓名、年份等。 3-然后是该数据发送到在我们礼堂展示的谷歌表格,以便学生知道他们的父母已经到达

It seems like this should work, but I'm missing something: Allowing for third party updates to Google Spreadsheets via email response?看起来这应该可行,但我错过了一些东西: 允许第三方通过 email 响应更新 Google 电子表格?

I understand (and can do) how to write a Script and publish as a WebApp, and even to add parameters to that WebApp that are passed as variables, but how do I choose which Google Sheet document to add the data to?我了解(并且可以做到)如何编写脚本并作为 WebApp 发布,甚至可以将参数添加到作为变量传递的 WebApp,但是如何选择将数据添加到哪个 Google Sheet 文档?

Since this is still conceptual, I don't have any examples, but would greatly appreciate some guidance.由于这仍然是概念性的,我没有任何示例,但非常感谢一些指导。 I have a decent understanding of coding/scripts, but I'm no expert.我对编码/脚本有很好的理解,但我不是专家。

I have figured it out.我已经想通了。 I was trying to write the Google Sheet WebApp in a seperate document, but I have now added it to the same document.我试图在单独的文档中编写 Google Sheet WebApp,但我现在已将其添加到同一个文档中。 Here is what I did:这是我所做的:

In a Google Sheet - Go to Extensions - Apps Scripts在 Google 表格中 - Go 到扩展 - 应用程序脚本

Use the following code in Code.gs:在 Code.gs 中使用以下代码:

function doGet(request) {
  Logger.log(request);
  
  var sheet = SpreadsheetApp.getActive().getSheetByName('Sheet1');
  var data = sheet.getDataRange().getValues();
  
  var user = request.parameters.id;
  var year = request.parameters.year;
  for (var i=1; i<data.length; i++) {
    if (data[i][0] == user[0]){
      sheet.getRange(i+1, 3,1,1).setValue(year[0]);
    }
  }
  var result = "Congratulations! You just said '" + year[0] + "' to " + user + ".";

  var cell = sheet.getRange(1,1);
  cell.setValue(year);
  var cell = sheet.getRange(1,2);
  cell.setValue(user);

  return ContentService.createTextOutput(result);
}

Then Deploy - New Development - Choose WebApp然后部署 - 新开发 - 选择 WebApp

Copy the WebApp URL and add?id=John&year=9 to the end like this: https://script.google.com/macros/s/AKfymany numbercj/exec?id=John&year=9复制 WebApp URL 并将?id=John&year=9 添加到末尾,如下所示: https://script.google.com/macros/s/AKfymany numbercj/exec?id=John&year=9

Put that into a QR code generator and when that code is scanned, the name appears in the Google Sheet document.将其放入 QR 码生成器中,当扫描该代码时,该名称会出现在 Google Sheet 文档中。

When I looked at the original example, it appeared that two Google Sheet documents were being used, so I couldn't see the link between the two.当我查看原始示例时,似乎使用了两个 Google Sheet 文档,因此我看不到两者之间的链接。 In fact the scpript that becomes a WebApp is attached to the same Google Sheets document.事实上,成为 WebApp 的脚本附加到同一个 Google 表格文档。

Thanks again for the responses.再次感谢您的回复。

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

相关问题 Google Data Studio Community Connector - 如何跨多个查看器共享凭据到第 3 方端点? - Google Data Studio Community Connector - How to share credentials to 3rd party endpoint accross multiple viewers? 无法从 Google 日历中的会议解决方案下拉菜单中使用 3rd 方会议解决方案创建会议 - Cannot create conference with 3rd party Conference Solution from conference solutions Dropdown in Google Calendar 谷歌表格触发写入单元格 - Google Sheets trigger writing to cell 将数据从 Google 工作表写入 Redshift - Writing data from Google sheets to Redshift Google Script onChange 3rd Party INSERT_ROW - Google Script onChange 3rd Party INSERT_ROW 在 Google 表格中获取指向此单元格的链接 - Get Link to this cell in Google sheets 使用第三张工作表中的单元格值将Google工作表复制到新工作表中 - Copy Google sheet to a new sheet using cell value from 3rd sheet 到 append 会议在谷歌日历的创建事件弹出窗口中单击来自第 3 方视频会议插件的按钮 - To append conference in google calendar's create event popup on click of button from 3rd party video conference plugin 将 2 个不同工作表中的 2 个副本之一复制到第 3 个工作表中 - Copy one of the 2 duplicates from 2 different sheets into the 3rd one onEdit 特定单元格将数据从一个谷歌表格复制到另一个 - onEdit specific cell copy data from one google sheets to another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM