Тёмный

Google Apps Script: How to export Google Sheets as PDF 

saperis
Подписаться 29 тыс.
Просмотров 39 тыс.
50% 1

In this video you will see how you can use Google Apps Script to export a Google Sheets document as a PDF.
00:00 Intro
00:10 What we will be automating
00:23 Create PDF export script
03:34 Create message sending script
05:05 Run the code
Want to learn how to be more productive with Google Workspace? 🤩
bit.ly/productivity-for-creat...
#GoogleAppsScriptSheetsPDF #GoogleAppsScript #AppsScript #GoogleWorkspace #saperis #ChanelGreco
-----
saperis - Helping you become a Google Workspace Pro!
Sign up to our RU-vid channel for more Google Workspace, Gmail, Google Apps Script, Google Drive, etc. videos: / saperis

Опубликовано:

 

23 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 140   
@alexanderbaranov5094
@alexanderbaranov5094 2 года назад
Thanks a lot!!! You've just saved tons of hours of my life! Moreover, everything is inspiring: the logic and style of explanation, air of the video, and your personal approach. Great job!
@saperis
@saperis 2 года назад
Happy to hear the video was useful! Automation is all about being more efficient so I'm really happy this video has helped you to save time.
@ivanurbina2422
@ivanurbina2422 Год назад
Love your tutorials. How to export google sheet to pdf was just what I needed. Thank You. I am subscribed to your wonderful tutorial❤️
@saperis
@saperis Год назад
Awesome, thank you! 😀
@dantevivero670
@dantevivero670 2 года назад
this is so new for me this GAS programming, a newbie :D excellent vid!
@saperis
@saperis 2 года назад
Welcome to the GAS community! Happy you liked the video.
@aG-kf8xf
@aG-kf8xf 2 года назад
suwun ya mbak....
@superbhatnagars
@superbhatnagars 2 года назад
Superb ma’am Thank you so much
@saperis
@saperis 2 года назад
Welcome 😊
@OptionToday
@OptionToday 2 года назад
Thank you sister
@saperis
@saperis 2 года назад
Welcome
@bachchuhaldar3783
@bachchuhaldar3783 2 года назад
Great video 👍👍👍
@saperis
@saperis 2 года назад
Glad you enjoyed it 😀
@WaxN-ey6vj
@WaxN-ey6vj 2 года назад
Your video is awesome! I think app script has a potential to be an alternative of Salesforce applications. I know app script allows you to have a html website and users can interact with data. I wonder if it has another GUI approach that anyone who is not familiar with coding can handle data manipulation.
@saperis
@saperis 2 года назад
Thanks for watching. Yes, you could have people add their data to a website if they might be intimidated by a spreadsheet.
@sirhenrymondeo
@sirhenrymondeo 2 года назад
Thank you so much for this tutorial. I have countless usecases for that! May I ask one question: the .setName('Revenue Stats ${currentMonth}'); statement should define the file name. In your script, the ${currentMonth} command is black and refers to the const "currentMonth". Here on my side the string ${currentMonth} is red and is not referring to the setting behind, so the final pdf is named "Revenue Stats ${currentMonth}" and does not replace the place holder with the actual month. Same in the email subject. Do you have any advise on this? Thx in advance.
@sirhenrymondeo
@sirhenrymondeo 2 года назад
Oh, so easy. I am posting the solution here. For setting the name use ` instead of '. ;-)
@saperis
@saperis 2 года назад
Yes. You need to use backticks and not common ticks. Looks almost the same but has a very different outcome.
@sdl9258
@sdl9258 2 года назад
Good
@saperis
@saperis 2 года назад
Thanks 😀
@andreaguerri.educational
@andreaguerri.educational 2 года назад
Sempre brava!
@saperis
@saperis 2 года назад
Grazie 😀😀
@andreaguerri.educational
@andreaguerri.educational 2 года назад
@@saperis ma sai anche l'italiano?🤩
@saperis
@saperis 2 года назад
@Andrea Guerri Si, un po.
@GenNextAnalyst
@GenNextAnalyst 2 года назад
Excellent and useful Chanel! Perhaps you can add ko-fi as a way to sustain and grow your YT.
@saperis
@saperis 2 года назад
Thanks for the tip! 😀
@joshuarein1860
@joshuarein1860 27 дней назад
This worked great, how do I add day and year to the "current month" portion of the code, what is the proper code?. I will be automatically sending out a pdf weekly and do not want 4 files with the same name (ex "Oil Report June", I need "Oil Report June 7 2024" or similar. Thanks
@joshuarmir
@joshuarmir 2 года назад
Thank you so much for this. I have one question...Instead of a month, I need a weekly report. How can I add that to the script? Thank you so much again. From Medellín, Colombia.
@saperis
@saperis 2 года назад
You would probably want to change the naming of the file to contain the week or the date. And then you would choose a weekly trigger instead of a monthly one.
@eighthkapsule4251
@eighthkapsule4251 Год назад
Thank you! So helpful. how do I name the PDF based on a cell value? For example: .set name (‘File Name - grabs cell value A1’); Thanks so much!
@saperis
@saperis Год назад
You would have to modify the script to get a value out of a certain cell and then using that as the name of the document.
Год назад
Hi, thanks for this tutorial. Is there a method to force the pdf orientation to "landscape" ? A parameter to add or something else ?
@saperis
@saperis Год назад
Not that I know of
@aljunnaag7052
@aljunnaag7052 2 года назад
This is very helpful! I would like to know though if it's possible to run this code so that (1) only a specific range is exported, and (2) change some PDF format options?
@saperis
@saperis 2 года назад
Check this blog post as it seems it's more what you are looking for than my video. xfanatical.com/blog/print-google-sheet-as-pdf-using-apps-script/
@aljunnaag7052
@aljunnaag7052 2 года назад
@@saperis Thank you for the link!
@1videoshow
@1videoshow 2 года назад
Hello is there a google sheets native format ? Can we download it to local disk for backup to creat a an exact copy? There is only windows xlsx ods and PDF and some text files in file download menu.
@saperis
@saperis 2 года назад
No, you can't download any of the Google file formats directly to your computer. That's why in the menu you can only choose non-Google formats to download. But there are backup solutions out there. I remember seeing this video that might be helpful: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-UiZYy-146_0.html
@raymondjackson2602
@raymondjackson2602 2 года назад
This is fantastic! Are you able to please provide a link to - or the actual copy/paste script? Sorry if it's obvious and I just missed it.
@saperis
@saperis 2 года назад
Thanks for watching. We don't share the code of the scripts directly. You get the script by copying as we write the code.
@ac24365
@ac24365 2 года назад
Great video! I wish to just export the rows having the current dates to the PDF every evening. How can I achieve that with your code mentioned here? Thanks
@saperis
@saperis 2 года назад
Hm. Not quite sure what the best option would be as it depends on your Sheets and your expectations. You would essentially be only copying data and so you would loose the spreadsheet layout. So it probably would be best to copy that new row into another Sheets and then export that one. But there might also be a more straight forward way of achieving your goal. Best you try it out.
@hasanmia94
@hasanmia94 Месяц назад
Thanks for your good video. I have been benefited by this one. Now please suggest me a code for delete the specific cells data of Google sheet by app script
@normantam
@normantam Год назад
Is there a way to customize this to export in landscape format? Thank you for the great video!
@saperis
@saperis Год назад
I don't think you can. The official documentation doesn't make any mention of passing in the paper format when creating a new file: developers.google.com/apps-script/reference/drive/folder#createfilename,-content,-mimetype
@jsg3217
@jsg3217 Год назад
Thanks for the really good lecture :) I have one question, is it possible to extract only one specific sheet from google spread sheet file?
@saperis
@saperis Год назад
Check this tutorial to see how you could possibly only export one sheet: stackoverflow.com/questions/38335143/export-single-sheet-to-pdf-in-apps-script
@sheetautomation365
@sheetautomation365 Год назад
Thanks for your video. If there are many sheets in the file. How could I export one specific sheet to pdf?
@saperis
@saperis Год назад
Check out this blog post to see how it's done: xfanatical.com/blog/print-google-sheet-as-pdf-using-apps-script/
@pepemiko
@pepemiko Год назад
Hello, I tried this with a Google Sheet and it works. A slight issue though is that the PDF being saved/emailed includes all of the sheets within the file. If I only want to have a specific sheet sent and saved as a PDF, how should the script be tweaked? I hope you can still answer my question. Thank you in advance!
@saperis
@saperis Год назад
Have a look at this blog post: xfanatical.com/blog/print-google-sheet-as-pdf-using-apps-script/
@mischagraafmans156
@mischagraafmans156 2 года назад
How would I go about for printing only one specific region of one specific sheet instead of the whole file? btw. Love how you do the presentation. Very professional.
@saperis
@saperis 2 года назад
Thanks for the feedback. 😀 Check this blog post to see how to export only a certain region. xfanatical.com/blog/print-google-sheet-as-pdf-using-apps-script/
@oluwayomidada3536
@oluwayomidada3536 Год назад
@@saperis splendid thanks, exactly what I needed. But don't really understand the script on the page. Please can we get a video on this issue....thanks u d best
@saperis
@saperis Год назад
@@oluwayomidada3536 Very sorry, but I don't do any Apps Script videos anymore.
@arifzainal8694
@arifzainal8694 Год назад
Amazing tutorial thank you so much. Can you please tell me how to convert and send a specific sheet name within the file, not the entire sheets? appreciated :)
@saperis
@saperis Год назад
Check this tutorial to see how you could possibly only export one sheet: stackoverflow.com/questions/38335143/export-single-sheet-to-pdf-in-apps-script
@arifzainal8694
@arifzainal8694 Год назад
@@saperis Thank you so much.
@sukhendu5
@sukhendu5 Год назад
it is very good code thanks to lot but one things when i write it is export this file in mobile but always ask to open with which format
@saperis
@saperis Год назад
If it doesn't work as expected you could maybe try to create the file with a different mimeType: developers.google.com/apps-script/reference/drive/drive-app#createfilename,-content,-mimetype
@rosarioaliuyvico3749
@rosarioaliuyvico3749 Год назад
Hi! just watched your video tutorial. just wanna ask how can i extract certain data from google sheets, arrange it on google docs then send it via pdf? thank u
@saperis
@saperis Год назад
You would have to write a new script for that. Check the official documentation to find out how to use Apps Script to achieve your goals: developers.google.com/apps-script
@brayandanilovelasquezjimen29
@brayandanilovelasquezjimen29 11 месяцев назад
Hi thanks for your video, I have a question, do you think it is possible to export it as and not as a pdf? I have searched and tried other methods but it does not work, thanks for your comments and suggestions.
@saperis
@saperis 11 месяцев назад
As what type of file do you want to export it?
@user-ez6nw9do5b
@user-ez6nw9do5b Год назад
Thank you, I got a question. There is any way I can export the PDF when I click a button and don't send the email, just open the PDF
@saperis
@saperis Год назад
Sure, you can do almost anything with Apps Script. Check the Apps Script documentation to find out how to achieve what you want to do: developers.google.com/apps-script/reference/spreadsheet
@oseebotendju9120
@oseebotendju9120 Год назад
Hello @Saperis, I hope you're going well. Please can you help us to make tutorial, on how we can convert to pdf each sheet into one SpreadSheet, or if you have some tips, you share them with us. thank you so much for your time and for what's you're doing. 🙌🏽
@saperis
@saperis Год назад
Thank you for your request. I don't do any Google Apps Script or Google Workspace videos anymore. Find out more in this video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-OHd_xEabivg.html
@oseebotendju9120
@oseebotendju9120 Год назад
@@saperis Thank you so much.
@72avl
@72avl Год назад
Great tutorial... sorry but I have to ask a question, I am getting a ReferenceError: Driveapp is not defined - any ideas? I tried scopes, etc... and nothing helps. Keep up the great work and thank you.
@saperis
@saperis Год назад
The error message tells you that you are using "Driveapp" but that doesn't exist. Note how I wrote "DriveApp" in my script. It has to be a capital A.
@khan.zia.99
@khan.zia.99 Год назад
I am running a similar task of creating pdf but im using a template and replacing placeholders with row data of google sheet. Function is creating blob and attaching it to email but the attachment doesn't show anything but only one word "blob". Can you please help me how i can solve the issue.
@saperis
@saperis Год назад
I'm guessing there is an error in our script. Try to find it by following this video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-L4V15ZxIjBQ.html
@joshuarmir
@joshuarmir 8 месяцев назад
Hello, me again. Can I get the email from another cell value? I mean, the email will change everytime.
@saperis
@saperis 8 месяцев назад
Sure. You are the creator of the script. So you decide how it works.
@user-yf1bj2lg9s
@user-yf1bj2lg9s 6 месяцев назад
Thanks for the tutorial. How can I modify this to export as csv file? I tried simply changing all references from pdf to csv, but I get the error "Converting from application/vnd.google-apps.spreadsheet to application.csv is not supported." Thanks!
@saperis
@saperis 6 месяцев назад
I'm not quite sure but I think CSV is not supported for what the script I wrote does. Check: ramblings.mcpher.com/gassnippets2/apps-script-file-conversions/ And also: github.com/prasmussen/gdrive/issues/303
@AtiAccurateTechnology
@AtiAccurateTechnology 6 месяцев назад
Alright thank you for the reply@@saperis . One would think exporting as csv would be the easiest function from sheets. Apparently not. I'll work around it.
@chirag2839
@chirag2839 Год назад
Hi, this is just what I needed, Would it be possible to just send one of the sheets PDF instead workbook?
@saperis
@saperis Год назад
Check this tutorial to see how you could possibly only export one sheet: stackoverflow.com/questions/38335143/export-single-sheet-to-pdf-in-apps-script
@chirag2839
@chirag2839 Год назад
@@saperis Thanks a lot
@Carnediporco
@Carnediporco 2 года назад
i need to export only one sheet in a multi sheet document, how can i do ?
@saperis
@saperis 2 года назад
You can only create a PDF from a spreadsheet and not from a single sheet within a spreadsheet. But after some research I think this might be the approach: - hide the other sheets within the spreadsheet - create your PDF of the spreadsheet (the hidden sheets are omitted) - un-hide the other sheets Here is where I read about this approach: stackoverflow.com/questions/38335143/export-single-sheet-to-pdf-in-apps-script
@seamllc2511
@seamllc2511 Год назад
Is there a way to do this with 100 different workbooks, first sheet only? and if there is, will it work if the top line is a merged cell? how to skip the top line if so. Thank you!
@saperis
@saperis Год назад
Well, those are some very specific questions. I've never done what you want to do but I, in theory, it should be possible. Obviously, you would have to adapt the script to your needs.
@seamllc2511
@seamllc2511 Год назад
@@saperis Yes, I'm looking to see what that script is. But this got me off to the right start. Thank you!
@sheetautomation365
@sheetautomation365 Год назад
Hi bro! If I only would like to export 1 sheet in the spreadsheet, How could I do? Thanks
@saperis
@saperis Год назад
Check out this blog post to see how it's done: xfanatical.com/blog/print-google-sheet-as-pdf-using-apps-script/
@nutricaosaquarema1102
@nutricaosaquarema1102 Год назад
Very good. There is a way to save only some sheets from a file?
@saperis
@saperis Год назад
Check this tutorial to see how you could possibly only export one sheet: stackoverflow.com/questions/38335143/export-single-sheet-to-pdf-in-apps-script
@nutricaosaquarema1102
@nutricaosaquarema1102 Год назад
@@saperis Thanks a lot
@aarondumapias6084
@aarondumapias6084 Год назад
Hi, your video help me. Can I ask on how to automatically set it into landscape when converting into pdf?
@saperis
@saperis Год назад
I don't know how to change the page orientation either.
@aarondumapias6084
@aarondumapias6084 Год назад
@@saperis Oh I see, thanks for your response! Looking forward for more tutorial
@gauravkandal
@gauravkandal 2 года назад
Thank you so much. Please guide how can we send single sheet from workbook.
@saperis
@saperis 2 года назад
You can only create a PDF from a spreadsheet and not from a single sheet within a spreadsheet. But after some research I think this might be the approach: - hide the other sheets within the spreadsheet - create your PDF of the spreadsheet (the hidden sheets are omitted) - un-hide the other sheets Here is where I read about this approach: stackoverflow.com/questions/38335143/export-single-sheet-to-pdf-in-apps-script
@gauravkandal
@gauravkandal 2 года назад
@@saperis Thank you for your support.
@sirhenrymondeo
@sirhenrymondeo 2 года назад
I had the similar challenge. My total Google Spreadsheet has 10+ sheets in it. I only need to export 4 special sheets as pdf regularly (these 4 sheets contain the reporting dashboards). So here is the work around: Create a completely new Google Spreadsheet and use the "Importrange" formula to mirror/autosync the sheet from the original spreadsheet you need to export. As a result, this new spreadsheet only contains the sheet you need to export. You can do that with as much sheets as you might need for your regular export. Finally, use the spreadsheet-id of this new mirrored spreadsheet as the basis for the script you learned in this video. You do not have to touch this new "mirror spreadsheet" anymore. Whenever there is a change in your main spreadsheet, the "importrange" function will update everything automatically in the mirror spreadsheet. If you need help, how to use this magic "importrange" function, watch this video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-5S7laJS9meU.html hope that helps! I have built lots of automated regular reports based on these two hacks and it spends me a ton of time. crazy!
@gauravkandal
@gauravkandal 2 года назад
@@sirhenrymondeo Yes this how we are doing !!
@abhishekranjan2617
@abhishekranjan2617 9 месяцев назад
Mam, I want to export only particular tab as pdf . How I would do that using app script????? Please help!!!
@saperis
@saperis 9 месяцев назад
Check the comments on this video. I've re-shared a tutorial to do so multiple times.
@mojoagung9122
@mojoagung9122 2 года назад
one question, i make that script for my spreadsheet that contain images in merged cell and the script isn't working. how do i solve this ?
@saperis
@saperis 2 года назад
I don't know as I've never had your exact situation. Maybe you could use the debugging mode to run your code to find out why it isn't working: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-L4V15ZxIjBQ.html
@tsubasanoshinin
@tsubasanoshinin Год назад
Pls help , how can I select just only one sheet that I am working on it and how can I customize the pdf file like A4 , lanscape ?
@saperis
@saperis Год назад
Check the comments as this has been asked many times and I always share a link to a tutorial you will want to check out.
@dyoncreab6761
@dyoncreab6761 7 месяцев назад
hi good day,,, how to make a print button and preview using spreadsheet ,, thanks
@saperis
@saperis 7 месяцев назад
Check this video to find out how you can add such a button: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Xd56y8GZbIM.html
@erickemmanuelmaderajorge6942
Hello, im getting this error: TypeError: reveneuStats.getAs is not a function, any idea how solve it?
@saperis
@saperis Год назад
The error means that you are trying to run a function that isn't one. Check your code for any typos. Be aware that whenever you want to call a function you have to make sure to add the parentheses at the end: functioName()
@prasadpatil9849
@prasadpatil9849 2 года назад
Thanks for the video. But I am getting following error - "TypeError: PI.getAs is not a function".
@saperis
@saperis 2 года назад
Please check your code again. Did you write all the necessary symbols? Any typos? The message is telling you that Pl.getAs is not a function. That could be because you didn't add the parentheses () or something similar.
@GrenadCika
@GrenadCika Год назад
how to choose some row and collum
@saperis
@saperis Год назад
Check the documentation to find out: developers.google.com/apps-script/reference/spreadsheet/sheet
@putrianarahmawati8550
@putrianarahmawati8550 2 года назад
How do I convert from multiple sheets?
@saperis
@saperis 2 года назад
If I'm not mistaking this script makes a PDF from a spreadsheet. So from the entire file including all the sheets within the file.
@manojsubramaniansankari5972
@manojsubramaniansankari5972 2 года назад
The following error message is seen. DriveApp is not defined Could you please guide me here?
@saperis
@saperis 2 года назад
Check your code again because you somehow aren't referencing the DriveApp correctly. Is there maybe a typo in your code?
@anshumsingal298
@anshumsingal298 2 года назад
How to share only a worksheet's range and not the whole google sheet as a pdf?
@saperis
@saperis 2 года назад
We have no video about how to do that. Maybe this article can help you: stackoverflow.com/questions/38335143/export-single-sheet-to-pdf-in-apps-script
@traviswarner3934
@traviswarner3934 Год назад
How can you send just one worksheet of a workbook?
@saperis
@saperis Год назад
Have a look at this tutorial: xfanatical.com/blog/print-google-sheet-as-pdf-using-apps-script/
@HRArchtech-fb8hk
@HRArchtech-fb8hk 10 месяцев назад
Mam if I need next month then what to do
@saperis
@saperis 10 месяцев назад
I guess you export it next month?
@HRArchtech-fb8hk
@HRArchtech-fb8hk 10 месяцев назад
@@saperis I want to do it for salary slip
@HRArchtech-fb8hk
@HRArchtech-fb8hk 9 месяцев назад
hello mam pls reply
@bibin2195
@bibin2195 Год назад
How to send Excel like this
@saperis
@saperis Год назад
Check this tutorial: spreadsheet.dev/comprehensive-guide-export-google-sheets-to-pdf-excel-csv-apps-script
@adityadeepakghadge5738
@adityadeepakghadge5738 2 года назад
Hallo I need your help I have lost of data in my spreadsheet and I want to make pdf a particular page with page set-up Please help me 🙏 Your video show whole spreadsheet data i want only a Particular page data to save as a pdf please help me
@saperis
@saperis 2 года назад
Maybe you could hide the sheets you don't want to have exported. Check this information to get an idea on how you could solve your problem: stackoverflow.com/questions/38335143/export-single-sheet-to-pdf-in-apps-script
@adityadeepakghadge5738
@adityadeepakghadge5738 2 года назад
Ohh 😂 Thanks a lot. 🙏
@adityadeepakghadge5738
@adityadeepakghadge5738 2 года назад
I this method page will not setup How to setup page like A3 ,A4 and Make pdf a particular sheet Can you help me please 🙏
@surveilanspuskesmascimarag9937
How can I print 2 pages?
@saperis
@saperis Год назад
You can't print with Apps Script as it doesn't have a way to connect to your computer or printer.
@surveilanspuskesmascimarag9937
@@saperis I mean how do I export to pdf but from specified sheet and want 2 pages
@JishiiCreations
@JishiiCreations 10 месяцев назад
I want to convert Pdf in Landscape
@saperis
@saperis 10 месяцев назад
I'd check Stackoverflow to see if you can find a code snippet there. I don't have one at hand myself.
@ggbin8092
@ggbin8092 8 дней назад
How to export as image
@anhnhatnguyet4628
@anhnhatnguyet4628 2 года назад
do you use Facebook? I need you support
@saperis
@saperis 2 года назад
Hey Anh. We don't offer any support for Google Apps Script projects or automations.
Далее
Google Apps Script Tutorial for Beginners
23:54
Просмотров 369 тыс.
НРАВИТСЯ ЭТОТ ФОРМАТ??
00:37
Просмотров 1,8 млн
Google Apps Script For Loop
19:09
Просмотров 19 тыс.
Google Apps Script Save Sheet to PDF
16:08
Просмотров 18 тыс.
НРАВИТСЯ ЭТОТ ФОРМАТ??
00:37
Просмотров 1,8 млн