google apps script - Copying selected row to presentation -
my goal copy row spreadsheet , merge row data using markers document (ideally google presentation) saves pdf can print.
i have figured out how have selected row copied object, can't life of me figure out how text copied kind of temporary document. have presentation template markers ready go.
here of scripts i've been working with.
function printrepairs() { var sheet = spreadsheetapp.getactivesheet(); var data = sheet.getdatarange().getvalues(); var row = sheet.getactiveselection(); //prints comma delim string of single row var row1 = data[1] logger.log("row #1: " + row1); var selectedrow = spreadsheetapp.getactiverange().getvalues(); // creates file selected row --doesn't work. browser.msgbox("the row selected contains: " +selectedrow); docslist.createfile('temp_row', selectedrow); copyblob(selectedrow); var folder = docslist.getfolder('temp'); folder.createfile('temp_row', 'hello', 'application/vnd.google-apps.document'); doc = documentapp.create("sheet_test"); documentapp.openbyid("sheet_test"); text.inserttext("sheet_test", selectedrow); browser.msgbox("the row selected contains: " +selectedrow); logger.log("the row selected contains: " + selectedrow); }
the operation you're performing commonly called "mail merge" . there google docs add-ons can - google doc go "add-ons > add-ons" , search "merge".
to same own script, recommend first familiar material in simple mail merge tutorial. instead of building email template in spreadsheet, you'll create new document document template.
create google doc template, markers match column headers in spreadsheet.
i have presentation template markers ready go.
unfortunately, there's no support presentations (yet). star issue 1573: presentation service google apps script. (maybe vote 1 gets done!)
for each row in spreadsheet...
- create copy of template doc.
driveapp.makecopy(name, destination)
. should use unique name each file, if don't you'll end multiple files same name on drive. - use
fileid
of new file, , open document.documentapp.openbyid(id)
- using technique similar this, this or this, search through document markers, , replace data spreadsheet.
- create copy of template doc.
Comments
Post a Comment