Google apps script 如何在文本区域内复制多行和多行文本并粘贴到工作表?

Google apps script 如何在文本区域内复制多行和多行文本并粘贴到工作表?,google-apps-script,textarea,copy-paste,multiline,multirow,Google Apps Script,Textarea,Copy Paste,Multiline,Multirow,我正在尝试将文本粘贴到文本区域并粘贴到工作表中,就像Ctrl+shift+V命令一样。下面的脚本仅粘贴在一个单元格中,但我希望粘贴工作表中跨越的方式(如Ctrl+shift+v中的复制和粘贴) 下面是html示例文件: teste.html <!DOCTYPE html> <html> <!-- Document Head --> <head> <meta charset="utf-8"> <meta name="

我正在尝试将文本粘贴到文本区域并粘贴到工作表中,就像Ctrl+shift+V命令一样。下面的脚本仅粘贴在一个单元格中,但我希望粘贴工作表中跨越的方式(如Ctrl+shift+v中的复制和粘贴)

下面是html示例文件: teste.html

<!DOCTYPE html>
<html>
  <!-- Document Head -->
  <head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
    <base target="_top">
    <!-- Add the Google Apps Script CSS file -->
    <link rel="stylesheet"     href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">

  <link rel="stylesheet"     href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js">    </script>

  <script>
  $( function() {
    $( "#tabs" ).tabs();
  } );
  </script>

<!-- Add Styling to your sidebar -->    
<!-- You can also refer to an external stylesheet - as with the link above or other css frameworks like Bootstrap or W3School's CSS -->
<!-- Try not to have styling elements within your html page and rather make of use external stylesheets -->
  <style>
    body {
      padding-left: 10px;
    }
    a:active {
      color: white;
      text-decoration: none:
   }
   a:hover {
      color: white;
      text-decoration: none:
   }
   a:link {
      color: white;
      text-decoration: none:
   }
   a:visited {
      color: white;
      text-decoration: none:
   }
   div {
      padding: 3px;
   }
    </style>
  </head>

  <!-- Document Body -->
  <body>

  <h2>Colar dados do GDL</h2>

<form id="myform">
  <div>
  <textarea  rows="150" cols="10" id = "textareagdl"     style="width:200px;height:150px;"></textarea>  
  </div>
  <div>
<button type="button"onclick="myFunction()">Copy</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("textareagdl").value;
    google.script.run.colargdl(x);
}
</script>

  </div>
</form>

</body>
</html>

关于

在谷歌应用程序脚本中,您可以调用
range.setValues()
一次填充多个单元格<代码>设置值采用二维值数组。您必须将文本区域的内容转换为二维数组。完成后,您可以调用
range.setValues()

您需要获取与数组的维度相匹配的范围-
工作表。getRange(行、列、numRows、numCols)
执行以下操作:

var data = [["one", "two", "three"], ["four", "five", "six"]];
var range = sheet.getRange(1, 1, data.length, data[0].length);
range.setValues(data);

抱歉,Aidan,它不工作,我的项目位于以下url中:
var data = [["one", "two", "three"], ["four", "five", "six"]];
var range = sheet.getRange(1, 1, data.length, data[0].length);
range.setValues(data);