/**
* VER ARTÍCULO EN MI SITIO WEB
* https://viktormorales.com/diseno-y-desarrollo-web/exportar-datos-de-hoja-de-calculo-a-una-presentacion-de-google/
*/
/**
* onOpen()
* This function is triggered when the current Spreadsheet is open
*/
function onOpen() {
createCustomMenu();
}
/**
* createCustomMenu()
* Create a custom menu on the current Spreadsheet
*/
function createCustomMenu() {
var menu = SpreadsheetApp.getUi().createMenu("Crear voucher");
menu.addItem("Exportar a PDF", "createVoucher");
menu.addToUi();
}
/**
* getFilesVariables()
* Set the IDs of the files and folders to work with
*/
function getFilesVariables() {
const filesId = {
"presentation": "PRESENTATION_ID", // Change this value to the Google Slides ID
"folder": "FOLDER_ID", // Change this value to the Folder ID where to save the PDF exported presentation file
"sheetName": "TAB NAME" // Change this value to the tab name of the presentation
}
return filesId;
}
/**
* createVoucher()
* This function is used to create the voucher
*/
function createVoucher() {
const filesVar = getFilesVariables();
// Get data from Google Sheets
const sheet = SpreadsheetApp.getActiveSpreadsheet();
const sheetName = filesVar["sheetName"];
const tab = sheet.getSheetByName(sheetName);
// Access an slide presentation
const presentation = SlidesApp.openById(filesVar["presentation"]);
const presentationName = presentation.getName();
// Get the last non-empty row values
const lastRow = getLastRowInColumn(tab);
const getRow = getRowData(tab, lastRow);
// If there is data on the sheet, continue with the process
if (lastRow > 1) {
// Mensaje
SpreadsheetApp.getActive().toast("Aguarde mientras se crea el archivo PDF");
// Create a COPY of the original slide presentation
const copy = DriveApp.getFileById(filesVar["presentation"]).makeCopy(`Copy ${presentationName}`);
const...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.