Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!