Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect several sheets in one #30

Open
oshliaer opened this issue Feb 21, 2019 · 1 comment
Open

Collect several sheets in one #30

oshliaer opened this issue Feb 21, 2019 · 1 comment
Assignees
Labels

Comments

@oshliaer
Copy link
Owner

oshliaer commented Feb 21, 2019

function copyMultipleSpreadsheet2(){
  var sheets = [];
  
  sheets.push(SpreadsheetApp.openById('ssssQ').getSheetByName('Sheet1'));
  sheets.push(SpreadsheetApp.openById('sssso').getSheetByName('Sheet1'));
  
  var data = sheets.reduce(function(p, c){
    var values = c.getRange('A2:D').getValues().filter(function(row){
      return row[0]!=='';
    });
    p = p.concat(values);
    return p;
  }, []);
  
  SpreadsheetApp.getActive().getSheetByName('Sheet1').getRange(1, 1, data.length, data[0].length).setValues(data);
}
``
@oshliaer
Copy link
Owner Author

oshliaer commented Feb 21, 2019

If you have a list of ids and sheets names on Sheet2 you gane generate sheets programmatic.

1550760555016

|       F       |    G    |
|:-------------:|:-------:|
| qwerqwerqwrwe | Sheet1  |
| asdfjkhasdkhf | Sheet1  |
| asdfasdfasdfj | Sheet10 |
var sheets = [];
// Getting a list of ids
sheets = SpreadsheetApp.getActive()
  .getRange('Sheet2!F:G')
  .getValues()
  .reduce(function(p, c) {
    if (c[0] !== '' && c[1] !== '')
      p.push(SpreadsheetApp.openById(c[0]).getSheetByName(c[1]));
    return p;
  }, []);

@oshliaer oshliaer self-assigned this Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant