【问题标题】:Update multiple rows of data in google sheet into multiple sections of google form将谷歌表格中的多行数据更新为谷歌表单的多个部分
【发布时间】:2020-04-12 02:25:06
【问题描述】:

目前使用以下应用程序脚本功能将一列数据更新到我的谷歌表单的一个部分。但是,我想编写一个代码,我可以将多行数据更新到谷歌表单的多个部分。

示例:第 1 列更新到第 1 节,第 2 列更新到第 2 节等等。

Google Sheet - Employee Names

function updateForm(){
  // call your form and connect to the drop-down item
  var form = FormApp.openById("Form Id");

  var namesList = form.getItemById("Dropdown List ID").asListItem();


// identify the sheet where the data resides needed to populate the drop-down
  var ss = SpreadsheetApp.getActive();
  var names = ss.getSheetByName("Sheet Name");

  // grab the values in the first column of the sheet - use 2 to skip header row
  var namesValues = names.getRange(2, 10, names.getMaxRows() - 1).getValues();

  var shopperNames = [];

  // convert the array ignoring empty cells
  for(var i = 0; i < namesValues.length; i++)   
    if(namesValues[i][0] != "")
      shopperNames[i] = namesValues[i][0];

  // populate the drop-down with the array data
  namesList.setChoiceValues(shopperNames);

}

【问题讨论】:

    标签: google-apps-script google-sheets google-forms


    【解决方案1】:

    为了更好的组织,请将数据整理如下

    姓名 - 地址

    这样您可以轻松添加新人并轻松更改地址。

    之后,通过B列过滤范围变得容易,您可以轻松获取街道上的人员列表。

    ArrayFormula 可以很容易地做到这一点

    https://sites.google.com/site/scriptsexamples/custom-methods/2d-arrays-library

    【讨论】:

    • 感谢您的提醒,但我不打算为此使用 arrayformula。我想将谷歌表格数据转移到谷歌表单下拉列表的一部分中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-18
    • 1970-01-01
    • 1970-01-01
    • 2023-02-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多