在Google表格网格和标题中添加换行符

时间:2018-09-07 15:47:47

标签: google-apps-script google-form

我目前正在使用以下Google脚本在问题中添加换行符:

function addLineBreaks() {
  var form = FormApp.getActiveForm(); 

  var multiplechoices = form.getItems(FormApp.ItemType.MULTIPLE_CHOICE);
  var date = form.getItems(FormApp.ItemType.DATE);
  var textbox = form.getItems(FormApp.ItemType.TEXT);
  var checkboxgrid = form.getItems(FormApp.ItemType.GRID)
  questions = multiplechoices.concat(date, textbox, checkboxgrid);

  for(i = 0; i < questions.length; i++) {
    var title = questions[i].getTitle();
    if(title.indexOf("\n") < 0) {
      questions[i].setTitle(title.replace(" | ", "\n"));
    }
  }
}

我的问题是我无法在网格行和常规标题(Tt)中添加换行符。我确信这是因为我正在使用的脚本引用了getTitle,但是无法使其与getRowssetRows一起使用。

我不介意添加“ |”并在脚本运行时将其替换为换行符,但是我确实需要找到有关网格的解决方案(仅适用于多选网格行)。

0 个答案:

没有答案