Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to create a pdf with google apps script that includes only a specific sheet of a spreadsheet?

In the spreadsheet app itself, you have the options to print only a specific sheet. You also can turn off the grid lines when creating the pdf from within the app. Is there any way to do this via script when creating the pdf?

like image 781
user1601777 Avatar asked Sep 14 '25 05:09

user1601777


2 Answers

Take a look at this code snippet: https://gist.github.com/4169590

What it does is uses Google Spreadsheet built-in download as PDF functionality so the same sort of customization is possible, including hiding gridlines and specifying a worksheet. Play with GET parameters to get the desirable output. In the end, script converts PDF file to a blob which you can manipulate further in your own script. To get this running though you'll need an additional authorization for Spreadsheet feeds scope.

Hope it helps.

like image 192
rcknr Avatar answered Sep 16 '25 20:09

rcknr


@rcknr, worked for me, more options below. (From: http://productforums.google.com/forum/#!msg/apps-script/wQvCF6yY1Qk/R0uyVmf-Xx0J )

URL like this: https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=tOHm3f8tdIxf7tSZzWvBGiA&gid=0&size=legal&fitw=true&gridlines=false&portrait=false&exportFormat=pdf

other settings

fmcmd=12
size=legal/A4
fzr=true/false
portrait=false/true
fitw=true/false
gid=0/1/2  
gridlines=false/true
printtitle=false/true
sheetnames=false/true
pagenum=UNDEFINED
attachment=false/true  

true/false where sometimes required, I could not use 0/1 instead.

like image 26
eddyparkinson Avatar answered Sep 16 '25 19:09

eddyparkinson