Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

185
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda