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

175
Visualizações
Convierta toda la hoja de Google a un archivo xlsx

He intentado modificar el siguiente script para convertir esencialmente una hoja de Google completa en un archivo xlsx, manteniendo los nombres de las pestañas iguales y ubicándolos en una carpeta,

El problema que estoy experimentando con lo siguiente es que está dividiendo cada pestaña en archivos separados, pero me gustaría mantenerlos todos juntos en un solo archivo.

https://webapps.stackexchange.com/questions/58615/exportar-todas-las-hojas-en-una-hoja-de-calculo-a-csv-en-google-apps

 function saveAsxlsx() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheets = ss.getSheets(); // create a folder from the name of the spreadsheet var folder = DriveApp.getFolderById('xxxxxxx'); for (var i = 0 ; i < sheets.length ; i++) { var sheet = sheets[i]; // append ".xlsx" extension to the sheet name fileName = sheet.getName() + ".xlsx"; // convert all available sheet data to xlsx format var xlsxFile = convertRangeToxlsxFile_(fileName, sheet); // create a file in the Docs List with the given name and the xlsx data folder.createFile(fileName, xlsxFile); } Browser.msgBox('Files are waitig in a folder named ' + folder.getName()); } function convertRangeToxlsxFile_(xlsxFileName, sheet) { // get available data range in the spreadsheet var activeRange = sheet.getDataRange(); try { var data = activeRange.getValues(); var xlsxFile = undefined; // loop through the data in the range and build a string with the xlsx data if (data.length > 1) { var xlsx = ""; for (var row = 0; row < data.length; row++) { for (var col = 0; col < data[row].length; col++) { if (data[row][col].toString().indexOf(",") != -1) { data[row][col] = "\"" + data[row][col] + "\""; } } // join each row's columns // add a carriage return to end of each row, except for the last one if (row < data.length-1) { xlsx += data[row].join(",") + "\r\n"; } else { xlsx += data[row]; } } xlsxFile = xlsx; } return xlsxFile; } catch(err) { Logger.log(err); Browser.msgBox(err); } }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

El script que está utilizando fue diseñado para obtener cada hoja como un archivo separado. En su lugar, puede consultar este ejemplo que convertirá Google Sheet a Excel XLSX Spreadsheet. Agregué un par de líneas al código para guardar el archivo en una carpeta en lugar de enviar un correo electrónico como lo hace el ejemplo.

 function getGoogleSpreadsheetAsExcel() { try { var ss = SpreadsheetApp.getActive(); var url = 'https://docs.google.com/feeds/download/spreadsheets/Export?key=' + ss.getId() + '&exportFormat=xlsx'; var folder = DriveApp.getFolderById('folderID'); //Add the folder ID of the folder where you want to save the file var params = { method: 'get', headers: { Authorization: 'Bearer ' + ScriptApp.getOAuthToken() }, muteHttpExceptions: true, }; var blob = UrlFetchApp.fetch(url, params).getBlob(); blob.setName(ss.getName() + '.xlsx'); folder.createFile(blob) } catch (f) { Logger.log(f.toString()); } }
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