Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
Combining Two Functions that Build Two Separate Arrays

I've been working on this script for two weeks now and can't figure it out. I think I need to combine these two functions to create one array and use the getSheetNames() function to be more of a descriptor. Then I want to run a separate function to filter the array into two different sheets on a master document based on sheet name. Any help would be greatly appreciated.

//Function to pull all data from workbook
function getDataFromSpreadsheet1(ssID) {
  
  //Open workbook
  let ss = SpreadsheetApp.openById(ssID);
  //Get all sheets in workbook and put into array
  let data = ss.getSheets().map(sh => sh.getRange(4, 1, sh.getLastRow() - 2, 3).getValues()).flat(1);
  Logger.log(data);
  return data;
  
}

//Function to return name of sheets in workbook
function getSheetNames(ssID) {

  let ss = SpreadsheetApp.openById(ssID);
  let sheets = ss.getSheets();
  let session = [];
  sheets.forEach(function (sheet) { 
    session.push(sheet.getName());
  });
  Logger.log(session);
  return session;

}
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Combining multiple Sheets of multiple spreadsheets

function getDataFromSpreadsheet1(ssID) {
  const ssids = ['ssID1', 'ssID2'];
  data = []
  ssids.forEach(ssid => {
    let ss = SpreadsheetApp.openById(ssid);
    let vs = ss.getSheets().map(sh => sh.getRange(4, 1, sh.getLastRow() - 2, 3).getValues()).flat(1);
    data.push(vs)
  })
  Logger.log(data);
  return data;
}

flat()

array

about 4 years ago · Juan Pablo Isaza Relatório

0

Here's what you need.

function getDataFromSpreadsheet1(ssID) {

  //Open workbook
  let ss = SpreadsheetApp.openById(ssID);
  //Get all sheets in workbook and put into array
  let data = ss.getSheets().map(sh =>{
        return [[sh.getName()],sh.getRange(4, 1, 3, 3).getValues().flat(1)]
  });

  console.log(data);
  return data;

}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda