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

147
Visualizações
Define multiple get Ranges and Sheet Names with javascript

I am using below script to pull date from all spreadsheets in a folder. It is strong and working.

now i would like to expand this script to define multiple different sheet names instead of one. that is because we have the same file in 3 different langueses, now when it is running and there is a file from an other langues it cannot find the sheet(name) so the script gives the error that GetRange is null. The data is the same, So Ill go through the files looking for

The sheets: "Gegevenskaart" || "DataCard" || "Datenkarte"

The Same for Range. in this specified Sheet I have 6 different ranges. they are all the same size and all have the same kind of data but there are rows that I dont want to use. (20 rows data, 25 empty rows in between)

The ranges to get data from are : [A15:BC34 ,A63:BC82 ,A11:BC130, A159:BC178 ,A207:BC226 ,A255:BC274, A300:3BC319] (also these data rows have a string in colomn A while the other rows dont have a string)

    function CombineDataToMasterFile() {                                                                    

  var folder = DriveApp.getFolderById("1234567890234567891234567");
  var filesIterator = folder.getFiles();
  var file;
  var fileType;
  var ssID;
  var combinedData = [];
  var data;

  while(filesIterator.hasNext()){
    file = filesIterator.next();
    fileType = file.getMimeType();
    if(fileType === "application/vnd.google-apps.spreadsheet"){
      ssID = file.getId();
      data = getDataFromSpreadsheet(ssID);
      data = data.map(function(r){return r.concat([file.getName()]); });
      combinedData = combinedData.concat(data);
    }
  }

  var ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Datatest");
  ws.getRange("A2:BC").clearContent();
  ws.getRange(2, 1, combinedData.length, combinedData[0].length).setValues(combinedData);
} 

function getDataFromSpreadsheet(ssID){

  var ss =  SpreadsheetApp.openById(ssID);
  var ws = ss.getSheetByName("Blad1");
  var data = ws.getRange("A15:BC34").getValues();
  return data;
about 4 years ago · Juan Pablo Isaza
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