1

OK so I think what I need doing is relatively complicated. At the moment we have a form which participants can fill out. We have a script implemented that means every time a form gets submitted it creates a new sheet within the spreadsheet the information is then passed through something similar to an IF function to change the Yes and No answers to 1 and 0. It looks like this:

//onFormSubmit
 function onFormSubmit(){
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Form Responses");
  var headings = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues();
  var lastRow = sheet.getRange(sheet.getLastRow(), 1, 1, sheet.getLastColumn()).getValues();
  var whoIsItFor = lastRow[0][1];

 if(ss.getSheetByName(whoIsItFor))
{
 var userSheet = ss.getSheetByName(whoIsItFor);
//if not make
} 
else 
{
var userSheet = ss.insertSheet(whoIsItFor);
userSheet.getRange(1, 1, 1, headings[0].length).setValues(headings);
}

// copy submitted data to user's sheet
userSheet.getRange(userSheet.getLastRow()+1, 1, 1, lastRow[0].length).setValues(lastRow);


var columns = new Array('K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ', 'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP', 'BQ', 'BR', 'BS', 'BT', 'BU', 'BV', 'BW', 'BX', 'BY', 'BZ', 'CA', 'CB', 'CC', 'CD', 'CE', 'CF', 'CG', 'CH', 'CI', 'CJ', 'CK', 'CL', 'CM');

for (var i = 0; i < columns.length; ++i)
{

c = columns[i] + "2";

if (userSheet.getRange(c).getValue() == "Yes") {
  userSheet.getRange(c).setValue("1")
}
else {
  userSheet.getRange(c).setValue("0")
}

}  



}

Now I want to implement the next stage. What I want to happen if for another sheet with various formulas and formatting to be added to the sheet that my current script generates and for the data generated from the form to be inserted within a certain column on that sheet that contains the formulas. I want this to happen every time the original script generates a new sheet. The sheet that contains the various formulas and formatting is contained within the same spreadsheet.

I hope this makes sense.....thank you very much in advance

4

1 回答 1

1

听起来(我可能是错的)你有一个真假问题的形式,每次提交表单都会将数据移动到一个新工作表,现在你想从一个“主工作表”移动所有功能和格式并插入它进入这个新创建的工作表。

难道你不能只创建一个你想要导入功能和格式的“主表”的副本吗?然后,您可以输入表单提交中的数据。

https://developers.google.com/apps-script/service_spreadsheet

我将直接离开他们的 API,因为我之前没有尝试过这个,但基本上,你会做一个像这样的新工作表

//make the new sheet
masterSheet.copyTo("nameOfNewSheet");
//fill data in as usual

如果我正确解释了您的问题,请告诉我。

于 2012-05-30T17:43:28.883 回答