google-apps-script - 使用脚本从 Google 表单写入 Google 表格
问题描述
所以我有一个谷歌表单,我正在使用脚本处理表单中的数据,我最终想将这些数据填充到电子表格中。我已经测试了我的代码并且记录器正在打印表单本身中的所有数据,但我的谷歌表仍然是空的。我怀疑我使用错误的代码写入工作表,但我不确定。我浏览了 Sheets API,它说我可以使用写入工作表appendRow
,并且可以选择使用哪个工作表写入openById()
,但这些似乎不起作用。我真的很感激任何见解!
这是我现在可以写入电子表格的代码,但它不起作用。
var array1 = [id, score]; // these are 2 variables that were initialized previously
array1 = array1.concat(array2);
// array2 is another array that I've initialized previously which works fine
// (I've tested both of these arrays in the Logger and it prints correctly)
var ss=SpreadsheetApp.openById(‘SSID’);
var sheet = ss.getSheetByName("Name");
sheet.appendRow(array1);
解决方案
所以在玩了一段时间之后,我意识到修复方法是简单地删除 onFormSubmit 触发器,然后再次运行它。不知道为什么要修复它,但我假设它没有准确同步/更新。感谢所有的帮助!
推荐阅读
- c# - 具有 EntityFrameworkCore.SQlite 的应用程序未在选定机器上运行
- c++ - 递归函数,查找以 0 开头并具有 0 和 1 的奇数序列的长度为 N 的二进制字符串的数量
- sql-server - LINQPad 6 连接到 SQL Server 2019 Docker 在登录前握手时出错
- unity3d - 如何在不运行 build all Bundles 的情况下生成 AssetBundleManifest 文件?
- winapi - MFC:如何从主线程使用 MsgWaitForMultipleObjects() 来等待多个线程完成使用 SendMessage()?
- javascript - 使用 Alpine js 与 $dispatch 进行组件通信
- python - 如何使用可变列标题从数据框的一列中提取一组行?
- javascript - dropzone.js `maxfilesexceeded` 事件没有被触发。以编程方式添加文件时
- python - 从数据框中重命名目录中的文件
- elasticsearch - ES集群启动时如何避免rebalance