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

318
Views
Hojas de cálculo de Google, informe de pila de varios libros de trabajo

Objetivo: apilar datos de más de 90 libros de trabajo de Google, todos con el mismo nombre de hoja, en una hoja maestra para generar informes

Información: Todas las hojas de cálculo tienen el mismo número de columnas. Tengo el siguiente script pero no se ejecuta correctamente, creo que el problema es cómo estoy almacenando en caché/empujando los datos a la matriz antes de pegarlos en la hoja de salida.

Estoy tratando de construir una matriz y luego pegarla de una sola vez.

Las tablas que estoy apilando tienen 47 columnas, número desconocido de filas. La parte que abre las hojas funciona perfectamente.

 // Get the data from the worksheets var indexsheet = SpreadsheetApp.getActive().getSheetByName("Index"); var outputsheet = SpreadsheetApp.getActive().getSheetByName("Output"); var response = SpreadsheetApp.getUi().prompt('Current Cycle', 'Enter Cycle Name Exactly in YY-MMM-Cycle# format', SpreadsheetApp.getUi().ButtonSet.OK_CANCEL) var CurrentCycleName = response.getResponseText() // Assign datasets to variables var indexdata = indexsheet.getDataRange().getValues(); // For each workbook in the index sheet, open it and copy the data to a cache indexdata.forEach(function(row, r) { try { //open Entity specific workbook var workbookid = indexsheet.getRange(r + 1, 7, 1, 1).getValues(); var Entityworkbook = SpreadsheetApp.openById(workbookid) // Open workhseet Entitysheet.getSheetByName(CurrentCycleName) // Add PR Data to cache - stacking for all countrys var PRDataCache = Entitysheet.getDataRange().push() } catch {} }) // Set the all values of the sheet at once outputsheet.getRange(r + 1, 14).setValue('Issue Splitting Data') Entitysheet.getRange(2, 1, PRDataCache.length || 1, 47).setValues(PRDataCache) };

Pestaña Índice Esta es la pestaña de índice de donde obtenemos el workbookid para abrir cada archivo

Ficha Salida Este es el archivo de salida, estamos apilando todos los datos de cada país

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que su objetivo es el siguiente.

  • Desea recuperar los ID de la hoja de cálculo de la columna "G" de la hoja "Índice".
  • Desea dar el nombre de la hoja específica mediante un cuadro de diálogo.
  • Desea recuperar todos los valores de la hoja de especificaciones en todas las hojas de cálculo. En este caso, desea eliminar la fila de encabezado.
  • Desea poner los valores recuperados en la hoja "Salida".

En este caso, ¿qué tal el siguiente script de muestra?

Guión de muestra:

 function myFunction() { var ss = SpreadsheetApp.getActive(); var indexsheet = ss.getSheetByName("Index"); var outputsheet = ss.getSheetByName("Output"); var response = SpreadsheetApp.getUi().prompt('Current Cycle', 'Enter Cycle Name Exactly in YY-MMM-Cycle# format', SpreadsheetApp.getUi().ButtonSet.OK_CANCEL); var CurrentCycleName = response.getResponseText(); var ids = indexsheet.getRange("G1:G" + indexsheet.getLastRow()).getValues(); var values = ids.reduce((ar, [id]) => { try { var [, ...values] = SpreadsheetApp.openById(id).getSheetByName(CurrentCycleName).getDataRange().getValues(); ar = [...ar, ...values]; } catch (e) { console.log(`"${id}" was not found.`); } return ar; }, []); if (values.length == 0) return; // If the number of columns is different in all Spreadsheets, please use the following script. // var maxLen = Math.max(...values.map(r => r.length)); // values = values.map(r => r.length < maxLen ? [...r, ...Array(maxLen - r.length).fill("")] : r); outputsheet.getRange(outputsheet.getLastRow() + 1, 1, values.length, values[1].length).setValues(values); }

Nota:

  • Cuando la cantidad de ID de hojas de cálculo es grande, el tiempo de procesamiento puede ser de más de 6 minutos. Estoy preocupado por esto. En ese momento, ¿qué hay de separar las ID de la hoja de cálculo?

Referencia:

  • reducir()
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!