apps脚本将输入工作表行单元格数据复制到输出工作表作为转置列数据

时间:2019-02-20 03:53:28

标签: google-apps-script google-sheets

试图将数据从输入页复制到已转置的输出页。第一次在图纸之间进行复印,不是很有经验。我已经尝试了许多方法来查看前面类似的stackoverflow报告来执行copyTo行代码。 错误“缺少;语句前。”(第11行,文件“代码”) 第11行是最后一行,inRng.copyTo ...

function fetchData() {
  //Browser.msgBox("Test Button");
  var inData = ("FUNGRAPH9");
  var outData = ("Data");
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var input = ss.getSheetByName(inData);
  var output = ss.getSheetByName(outData);
  //test getting data for 1st chart
  inRng = input.getRange(10,3,1,7); 
  outRng = output.getRange(6,21,12,21); 
  inRng.copyTo(outData,6,21,12,21).CopyPasteType.transposed);
}

Tanaike回答后的修订代码。现在可以使用了。谢谢!

  function fetchData() {
  //Browser.msgBox("Test Button");
  var inData = ("FUNGRAPH9");
  var outData = ("Data");
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var input = ss.getSheetByName(inData);
  var output = ss.getSheetByName(outData);
  //test getting data for 1st chart
  inRng = input.getRange(10,3,1,7);
  outRng = output.getRange("U6");
  inRng.copyTo(outRng, SpreadsheetApp.CopyPasteType.PASTE_NORMAL, true);
}

1 个答案:

答案 0 :(得分:0)

我使用了Tanaike的答案(针对我的更正案例进行了修改),并且有效,更正了代码:

  function fetchData() {
  //Browser.msgBox("Test Button");
  var inData = ("FUNGRAPH9");
  var outData = ("Data");
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var input = ss.getSheetByName(inData);
  var output = ss.getSheetByName(outData);
  //test getting data for 1st chart
  inRng = input.getRange(10,3,1,7);
  outRng = output.getRange("U6");
  inRng.copyTo(outRng, SpreadsheetApp.CopyPasteType.PASTE_NORMAL, true);
}