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

223
Views
¿Cómo crear un documento de Google para cada fila de una hoja de cálculo?

¡Yo! Este es mi código que usa la última línea de una hoja de cálculo para generar un documento de Google, además, coloca un enlace a este documento en la hoja de cálculo de origen. ¿Es posible crear un código que haga esto para todas las filas de una hoja de cálculo? Tengo problemas para usar .range() para leer las líneas individualmente. La razón de esto es simplemente mantener y actualizar los datos generados frente a los actualizados.

De antemano, ¡gracias!

 var app=SpreadsheetApp.openById("Google ID"); var sheet=app.getSheetByName('Respostas ao formulário 1') function autoFillLastRow() { var range=sheet.getDataRange().getValues(); var elem = range.pop(); //e.values is an array of form values var timestamp = elem[0]; //conversor de datas let data = new Date(timestamp); let dataFormatada = ((data.getDate() )) + "/" + ((data.getMonth() + 1)) + "/" + data.getFullYear(); var firstName = elem[1]; var lastName = elem[2]; var title = elem[3]; //file is the template file, and you get it by ID var file = DriveApp.getFileById('Google Drive ID'); //We can make a copy of the template, name it, and optionally tell it what folder to live in //file.makeCopy will return a Google Drive file object var folder = DriveApp.getFolderById('Google Drive ID') var copy = file.makeCopy(dataFormatada + ', ' + firstName, folder); //Once we've got the new file created, we need to open it as a document by using its ID var doc = DocumentApp.openById(copy.getId()); //Since everything we need to change is in the body, we need to get that var body = doc.getBody(); //Then we call all of our replaceText methods body.replaceText('{{Nome}}', firstName); body.replaceText('{{Sobrenome}}', lastName); body.replaceText('{{Título}}', title); //Lastly we save and close the document to persist our changes doc.saveAndClose(); //edit cell var coluna = 5; var linha = sheet.getLastRow(); var docId = doc.getId(); sheet.getRange(linha, coluna,1,1).setValue("https://docs.google.com/document/d/" + docId); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Crear documento para cada fila de la hoja de cálculo

 function createDocforEveryRowofSpreadsheet() { var ss = SpreadsheetApp.openById("Google ID"); var sh = ss.getSheetByName('Respostas ao formulário 1') var file = DriveApp.getFileById('Google Drive ID'); var folder = DriveApp.getFolderById('Google Drive ID') var [hA,...vs] = sh.getDataRange().getValues(); vs.forEach((r,i) => { var ts = r[0]; let data = new Date(ts); let dataFormatada = Utilities.formatDate(new Date(ts), Spreadsheet.getSpreadsheetTimeZone(), "dd/MM/yyyy") var firstName = r[1]; var lastName = r[2]; var title = r[3]; var copy = file.makeCopy(dataFormatada + ', ' + firstName, folder); var doc = DocumentApp.openById(copy.getId()); var body = doc.getBody(); body.replaceText('{{Nome}}', firstName); body.replaceText('{{Sobrenome}}', lastName); body.replaceText('{{Título}}', title); doc.saveAndClose(); }) }
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!