【问题标题】:Copy Dialog Box Response to a Cell将对话框响应复制到单元格
【发布时间】:2019-03-01 01:33:44
【问题描述】:

所以我对谷歌脚本有点陌生,我不确定我到底做错了什么。我正在尝试将结果从对话框复制到谷歌表格中的单元格。但是,我正在尝试的当前方法不起作用,并且我收到一条回复说“无法在对象(响应)中找到 CopyTo 的函数”

function Cancel() {
  var ui = SpreadsheetApp.getUi();

  var result = ui.prompt(
      'What day did you cancel?',
      'Please enter the date as mm/dd/yyy',
      ui.ButtonSet.OK_CANCEL);

  // Process the user's response.
  var button = result.getSelectedButton();
  var text = result.getResponseText();
  var sheet = SpreadsheetApp.getActiveSheet(),
    row = sheet.getLastRow();

  if (button == ui.Button.OK) {
    // User clicked "OK".
    sheet.insertRowAfter(row);
      text.copyTo(sheet.getRange(row + 1, 1));
    ui.alert('The Date has Been Recorded');
  } else if (button == ui.Button.CANCEL) {
    // User clicked "Cancel".
    ui.alert('I did not get your name.');
  } else if (button == ui.Button.CLOSE) {
    // User clicked X in the title bar.
    ui.alert('You closed the dialog.');
  }
}

谁能看看我的代码并就如何将响应复制到单元格提出建议。任何帮助将不胜感激。

【问题讨论】:

    标签: google-apps-script copy prompt


    【解决方案1】:

    怎么样:

    而不是:text.copyTo(sheet.getRange(row + 1, 1));

    试试:sheet.getRange(row + 1, 1).setValue(text);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多