Skip to content Skip to sidebar Skip to footer

Concatenation Of Single Quote Marks Google Script

I have three columns of data selector label option list time you personally have been engaged with uscan label_1 Arts time you p

Solution 1:

How about this modification?

Modification points :

  • About result[i]
    • " was escaped like \".
    • Line break was added like \n.
  • Remove the empty cells by filter().

Modified script :

function OptionsList() {
  var sheet =SpreadsheetApp.getActiveSpreadsheet().getSheetByName("OptionList");
  var lr = sheet.getLastRow();
  var values = sheet.getRange(2, 1, lr, 3).getValues();
  values = values.filter(function(e){return e[0] && e[1] && e[2]}); // Addedvar result = [];
  //Add items to resultsfor(var i=0; i<values.length; i++){ // Modified
    result[i] = ["option {\nlabel: \""+ values[i][1] +";\n"+"selector: [\""+ values[i][0] +"\"=\""+ values[i][2] +"\"];\n}"]; // Modified
  }
  //Post back to column 4 starting on row 2
  sheet.getRange(2, 4, result.length, 1).setValues(result); // Modified
}

Note :

  • For example, is it required to be " after "Label_1 of label: "Label_1;? If you want, please modify as follows.
    • + values[i][1] + "\";\n"

Reference :

If I misunderstand your question, please tell me. I would like to modify it.

Post a Comment for "Concatenation Of Single Quote Marks Google Script"