简体   繁体   English

如何使用 Google App Script 将一个 Google Sheet 中的所有数据提取到另一个 Google Sheet Tab?

[英]How do I pull All data in one Google Sheet to another Google Sheet Tab using Google App Script?

My manager and I are stuck!我和我的经理被困住了!

What we are trying to do is pull all of the data from one google sheet to the first tab on another google sheet using google App Script.我们正在尝试做的是使用谷歌应用脚​​本将所有数据从一个谷歌工作表拉到另一个谷歌工作表上的第一个标签。 They are located in 2 separate folders as well.它们也位于 2 个单独的文件夹中。

We don't want to use =importrange() basic because it doesn't actively update the sheet!我们不想使用 =importrange() basic 因为它不会主动更新工作表! We are trying to automate our systems!我们正在努力使我们的系统自动化!

we tried using this and it was a no go.我们尝试使用它,但这是行不通的。

function CopyRange() {
 var sss = SpreadsheetApp.openById('1vuqVDFLYc0pee0qITCQoL6ZXAOlzVl5Efg88F8mA39I'); //replace with source ID
 var ss = sss.getSheetByName('Bob Swope - Flow'); //replace with source Sheet tab name
 var range = ss.getRange('A2:AL1000'); //assign the range you want to copy
 var data = range.getValues();
 var tss = SpreadsheetApp.openById('17SZH2yKWuD1fonf-hOV1bpUumuOf5S24NI_V2Q0ITWo'); //replace with destination ID
 var ts = tss.getSheetByName('input'); //replace with destination Sheet tab name

}
function movingData() {
  var sss=SpreadsheetApp.getActive();//assuming this script is contained within this spreadsheet other you might wish to use openById();
  var dss=SpreadsheetApp.openById('SSID');//open destination spreadsheeet by id
  var dsh=dss.getSheets()[0];//first sheet on the left
  var shts=sss.getSheets();//array of all sheets
  //loop through all sheets getting data and appending to dsh
  shts.forEach(function(sh,i){
    var v=sh.getDataRange().getValues();
    dsh.getRange(dsh.getLastRow()+1,1,v.length,v[0].length).setValues(v);
  });
}

Class SpreadsheetApp 类电子表格应用程序

Assuming that you might wish to exclude some sheets from the source.假设您可能希望从源中排除一些工作表。 Then something like this might be useful.那么这样的事情可能会有用。

function movingData() {
  var exclA['Sheetnames','To','Exlude']
  var sss=SpreadsheetApp.getActive();
  var dss=SpreadsheetApp.openById('SSID')
  var dsh=dss.getSheets()[0];
  var shts=sss.getSheets();
  shts.forEach(function(sh,i){
    if(exclA.indexOf(sh.getName())==-1) {
      var v=sh.getDataRange().getValues();
      dsh.getRange(dsh.getLastRow()+1,1,v.length,v[0].length).setValues(v);
    }
  });
}

暂无
暂无

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

相关问题 如何让 Snipe-IT API 使用 Google 应用脚本检索数据并将其填充到 Google 表格中? - How do I get Snipe-IT API to retrieve data using a Google App Script and populate it on a Google Sheet? 如何从 Google App Scripts 中的另一个工作表中提取数据验证 - How to pull data validation from another sheet in Google App Scripts Firebase | 谷歌表 | 应用脚本 | 如何将列中的数据而不是行中的数据从 Firebase 保存到 Google 表格? - Firebase | Google Sheet | App Script | How do I save the data in column instead of row from Firebase to Google Sheet? 如何使用 JavaScript/Google App 脚本在 Google 表格中连续映射 arrays - How do I get arrays mapped in a row in google sheet using JavaScript/Google App script 如何使用 Google 脚本从 1 个 Google 工作表中复制特定值并粘贴到另一个工作表? - How can I copy specific values from 1 Google Sheet and paste to another Sheet using Google Script? Google 工作表应用程序脚本 - 根据循环条件将数据从一张工作表复制到另一张工作表 - Google sheet app script - Copy data from one sheet to another based on condition with loop 使用 Google App 脚本将数据从一张工作表复制到另一张工作表时执行缓慢 - Slow Execution for Copying Data from One Sheet to Another Using Google App Script 如何使用谷歌脚本覆盖具有相似名称和数据的现有谷歌表格? - How do I overwrite existing google sheet with similar name and data using google script? 如何修改此Google脚本以从Google表格中的E列提取电子邮件? - How do I modify this Google script to pull the email from column E in the Google sheet? 如何使用JavaScript在Google Picker中下载Google表格? - How do I download a Google Sheet with Google Picker all in JavaScript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM