GoogleForms对GoogleSheets中Next Blank Line的回复

时间:2017-04-18 17:45:16

标签: google-apps-script google-sheets

我正在尝试将GoogleForms响应放在特定工作表的下一个空白行中(请参阅Sample Data)。使用来自@ Mr.Rebot的recommendation时出现问题:附加到我的GoogleSheets文件的脚本似乎缺少某些东西,因为它没有产生任何可见的结果。

注意:项目的触发器= onEdit ||| From spreadsheet ||| On form submit

请参阅下面的当前代码:

function onEdit(e) {
   var form = FormApp.openById('1YLnK8kw2dRMUUvL1l3s4qjz9fSRIe7kj92MlPV5WV5M');
 var formResponses = form.getResponses();
 for (var i = 0; i < formResponses.length; i++) {
   var formResponse = formResponses[i];
   var itemResponses = formResponse.getItemResponses();
   for (var j = 0; j < itemResponses.length; j++) {
     var itemResponse = itemResponses[j];
     Logger.log('Response #%s to the question "%s" was "%s"',
         (i + 1).toString(),
         itemResponse.getItem().getTitle(),
         itemResponse.getResponse());
   }
 }
  var ss = SpreadsheetApp.getActiveSheet();
  ss.insertRowAfter(ss.getLastRow());
  ss.getRange(ss.getLastRow(),1,1,ss.getLastColumn()).copyTo(ss.getRange(ss.getLastRow()+1,1));
}

0 个答案:

没有答案