我试图从Google表单获取在多选择网格中输入的选项。我可以按行获取行,列但不是选择的行。
function Test_Field() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var process = ss.getSheetByName("Process TEST");
var sheet = ss.getSheetByName("Réponses au formulaire 3");
process.activate();
process.getRange(1, 1, sheet.getMaxRows(),
sheet.getMaxColumns()).clearContent();
var button = ("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
var form = FormApp.openByUrl(button);
var reps = form.getResponses();
var items = form.getItems();
var rep = reps[5]; //// I want only work on the 5 respons
var l = 3;
for (var i = 0; i < items.length; i++){
var index = items[i].getIndex();
var l = l+3;
process.getRange(l+1,1).setValue(i);
process.getRange(l+1,3).setValue(index);
process.getRange(l+1,3).setValue(items[i].getType());
if(items[i].getType() == "GRID") {
process.getRange(l+1,4).setValue("GRID");
var testitem = items[i].asGridItem().getRows();
var testitemcol = items[i].asGridItem().getColumns();
var itemResponses = rep.getItemResponses();
for (iii = 0;iii < testitem.length;iii++){
var itemResponse = itemResponses[iii];
process.getRange(l+1,iii+6).setValue(itemResponse);
process.getRange(l+2,iii+7).setValue(testitem[iii]);
process.getRange(l+3,iii+7).setValue(testitemcol[iii]);
}
}
if (itemsrep[i] != null)
{process.getRange(l+1,5).setValue(itemsrep[i].getResponse())};
}
}
答案 0 :(得分:0)
我用这个: 我检查了响应来自网格我正在寻找项目标题并将其链接到响应。
//Choose where from come your response
var formResponse = responses[i];
var itemResponses = formResponse.getItemResponses();
var items = form.getItems();
for (var j = 0; itemResponses.length - 1; j++) {
var itemResponse = itemResponses[j];
var tt = itemResponse.getItem().getType();
if (tt = 'GRID') {
var gridItmRows = itemResponses[j].asGridItem().getRows();
var gridResponse = itemResponses[j].getResponse();
for (var k = 0; k < gridResponse.length; k++){
//Set title - row's value
sheet.getRange(counter, 1).setValue(gridItmRows[k]);
//set answer - column's value
sheet.getRange(counter, 3).setValue(gridResponse[k]);
counter = counter + 1;
}
}
希望它有所帮助。