当前位置:首页 > 未分类 > 正文内容

Merge Multiple Google Spreadsheets into One

ceacer3周前 (05-02)未分类7725

Google Spreadsheets include an import features to help you copy subsheets from another spreadsheet into the currently open sheet. If you however need to merge multiple sheets, Google Scripts can help. Put them all in one folder and run a script that will create a master sheet will all the sheets pulled from other sheets.

function mergeSheets() {
  /* Retrieve the desired folder */
  var myFolder = DriveApp.getFoldersByName(SOURCE).next();

  /* Get all spreadsheets that resided on that folder */
  var spreadSheets = myFolder.getFilesByType('application/vnd.google-apps.spreadsheet');

  /* Create the new spreadsheet that you store other sheets */
  var newSpreadSheet = SpreadsheetApp.create('Merged Sheets');

  /* Iterate over the spreadsheets over the folder */
  while (spreadSheets.hasNext()) {
    var sheet = spreadSheets.next();

    /* Open the spreadsheet */
    var spreadSheet = SpreadsheetApp.openById(sheet.getId());

    /* Get all its sheets */
    for (var y in spreadSheet.getSheets()) {
      /* Copy the sheet to the new merged Spread Sheet */
      spreadSheet.getSheets()[y].copyTo(newSpreadSheet);
    }
  }
}

相关文章

How to Create Personalized Images in Bulk with Google Sheets

How to Create Personalized Images in Bulk with Google Sheets

Yesterday marked Friendship Day, and to celebrate, I sent a personalized image to each of my friends...

How to Email Google Sheets Automatically on a Recurring Schedule

How to Email Google Sheets Automatically on a Recurring Schedule

The Email Spreadsheets add-on for Google Sheets can save office workers a ton of time by automating...

How to Transcribe Audio and Video Attachments in Gmail

How to Transcribe Audio and Video Attachments in Gmail

The Save Gmail to Google Drive add-on lets you automatically download email messages and file attach...

How to Sort Google Sheets Automatically with Apps Script

How to Sort Google Sheets Automatically with Apps Script

This Google Spreadsheet on Udemy courses has about 50 sheets, one for each programming language, and...

How to Use Conditional Logic in Google Documents

How to Use Conditional Logic in Google Documents

Conditional content allows you to customize your Google Docs template and generate different version...

Color Codes for Google Spreadsheets

This Google Script converts the currently active Google Spreadsheet into a square grid of randomly c...