Skip to content

Instantly share code, notes, and snippets.

@rheajt
Last active December 11, 2019 04:02
Show Gist options
  • Save rheajt/162199c28a20aa3d0c24ebe8353979d8 to your computer and use it in GitHub Desktop.
Save rheajt/162199c28a20aa3d0c24ebe8353979d8 to your computer and use it in GitHub Desktop.
[slide data templates] auto-magically pull data from a spreadsheet into a slidedeck #gaspowered

Slide Data Templates

Just a simple demonstration of one way to turn a slide deck into a template for Spreadsheet Data.

https://youtu.be/rorblh4uWnM

Slide Data Templates

function onOpen() {
SlidesApp.getUi().createMenu('Template')
.addItem('Build template', 'buildTemplate')
.addToUi();
}
function buildTemplate() {
var presentation = SlidesApp.getActivePresentation();
var newPresentation = DriveApp.getFileById(presentation.getId())
.makeCopy('COPY OF TEMPLATE');
var template = SlidesApp.openById(newPresentation.getId());
var vals = getCurrentRow();
template.replaceAllText('<<NAME>>', vals[1], true);
template.replaceAllText('<<VALUE>>', vals[2], true);
}
function getCurrentRow() {
var ss = SpreadsheetApp.openById('1jJYJc3M0uoJIqPCyvx3Y1_I2dZcDMr5wpRvdoZhiIe4');
var sheet = ss.getActiveSheet();
var vals = sheet.getDataRange().getValues();
return vals[vals.length - 1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment