简体   繁体   English

Google脚本 - 将数据从一个工作簿复制到另一个工作簿 - importrange()替代方案

[英]Google Script - Copy Data from one Workbook To Another - importrange() Alternative

Recently, I have been seeing more and more failures of importrange() on various workbooks so i am toying with the idea of setting up a script to copy data from one sheet to another and put the script on a timer. 最近,我在各种工作簿上看到越来越多的importrange()失败,所以我想要设置一个脚本将数据从一个工作表复制到另一个工作表并将脚本放在一个计时器上。 The trouble is, even though its not a lot of data, it still exceeds the maximum execution time. 麻烦的是,即使它不是很多数据,它仍然超过了最大执行时间。 Any thoughts on how i can resolve this (Besides making the range smaller and processing smaller chunks of data)? 关于如何解决这个问题的任何想法(除了使范围更小并处理更小的数据块)? Here is my code: 这是我的代码:

function CopyData() {
//Clear DataSheet
  SpreadsheetApp.openById('12ZS...').getSheetByName('DataSheet').getRange('A:C').clearContent();

//Copy new database data
  var SData = SpreadsheetApp.openById('1cnNN...').getSheetByName('QuoteCounts').getRange('M1:O5000').getValues();
  SpreadsheetApp.openById('12ZS...').getSheetByName('DataSheet').getRange('A1:C5000').setValues(SData);
}

Try this: 尝试这个:

function CopyData() {
  var ss=SpreadsheetApp.openById('12ZS...')
  ss.getSheetByName('DataSheet').getRange('A:C').clearContent();
  var SData = SpreadsheetApp.openById('1cnNN...').getSheetByName('QuoteCounts').getRange('M1:O5000').getValues();
  ss.getSheetByName('DataSheet').getRange(1,1,SData.length,SData[0].length).setValues(SData);
}

You could also do it this way: 你也可以这样做:

function CopyData() {
  var ss=SpreadsheetApp.openById('12ZS...')
  ss.getSheetByName('DataSheet').getRange('A:C').clearContent();
  var sdrg=SpreadsheetApp.openById('1cnNN...').getSheetByName('QuoteCounts').getRange('M1:O5000');
  var SData =sdrg.getValues();
  ss.getSheetByName('DataSheet').getRange(1,1,sdrg.getHeight(),sdrg.getWidth()).setValues(SData);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将数据从一个 Google 工作表工作簿工作表复制到另一个工作簿 - Copy Data from One Google sheets Workbook Sheet to another Workbook 甚至可以使用脚本将数据从一张纸复制到另一张纸吗? ImportRange样式? - Is it even possible to copy data from one sheet to another with a script? ImportRange style? 将数据从一张纸复制到另一张 - Google Script - Copy Data from one sheet to another - Google Script 使用 Google App Script 将所有数据从一张纸复制到另一张纸 - Copy all data from one sheet to another with Google App Script 无需导入即可将内容从一个电子表格复制到另一个电子表格 - Copy content from one spreadsheet to another without IMPORTRANGE 将一个工作簿中的值粘贴到另一个工作簿底部的脚本-Google表格 - Script to paste values from one workbook into the bottom of another - google sheets 将数据从一个工作簿提交到另一个工作簿 - submit data from one workbook to another workbook 将数据从一个Google工作表工作簿移动到另一个工作簿 - Move Data From one google sheet workbook to another 在谷歌应用脚​​本中将数据从一张表复制到另一张表并附加一行,一个小问题 - copy data from one sheet to another in google app script and append a row, one small issue 使用脚本和网络应用将数据从Google表格的一张复制到另一张 - Copy data from one sheet of Google Sheet to another with script and web-app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM