Just a simple demonstration of one way to turn a slide deck into a template for Spreadsheet Data.
Last active
December 11, 2019 04:02
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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