Google Apps Script: How to export Google Sheets as PDF

Поділитися
Вставка
  • Опубліковано 5 вер 2024

КОМЕНТАРІ • 143

  • @alexanderbaranov5094
    @alexanderbaranov5094 2 роки тому +4

    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.

  • @joshuarein1860
    @joshuarein1860 2 місяці тому

    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

  • @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! 😀

  • @WaxN-ey6vj
    @WaxN-ey6vj 2 роки тому +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.

  • @hasanmia94
    @hasanmia94 2 місяці тому

    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

  • @aG-kf8xf
    @aG-kf8xf 2 роки тому

    suwun ya mbak....

  • @SaschaColussi
    @SaschaColussi 10 днів тому

    Is there a way I can time this export to be done once a week?

  • @abhishekranjan2617
    @abhishekranjan2617 10 місяців тому +1

    Mam, I want to export only particular tab as pdf . How I would do that using app script?????
    Please help!!!

    • @saperis
      @saperis  10 місяців тому

      Check the comments on this video. I've re-shared a tutorial to do so multiple times.

  • @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

  • @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.

  • @superbhatnagars
    @superbhatnagars 2 роки тому

    Superb ma’am Thank you so much

  • @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/

  • @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! 😀

  • @brayandanilovelasquezjimen29

    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  Рік тому +1

      As what type of file do you want to export it?

  • @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  Рік тому +1

      Check out this blog post to see how it's done: xfanatical.com/blog/print-google-sheet-as-pdf-using-apps-script/

  • @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

  • @OptionToday
    @OptionToday 2 роки тому

    Thank you sister

  • @oseebotendju9120
    @oseebotendju9120 2 роки тому

    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  2 роки тому +1

      Thank you for your request. I don't do any Google Apps Script or Google Workspace videos anymore. Find out more in this video: ua-cam.com/video/OHd_xEabivg/v-deo.html

    • @oseebotendju9120
      @oseebotendju9120 2 роки тому

      @@saperis Thank you so much.

  • @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 роки тому +1

      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.

  • @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

  • @mischagraafmans156
    @mischagraafmans156 2 роки тому +3

    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 роки тому +3

      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  Рік тому +1

      @@oluwayomidada3536 Very sorry, but I don't do any Apps Script videos anymore.

  • @user-yf1bj2lg9s
    @user-yf1bj2lg9s 8 місяців тому

    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  8 місяців тому +1

      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 8 місяців тому

      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.

  • @eighthkapsule4251
    @eighthkapsule4251 2 роки тому

    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  2 роки тому

      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.

  • @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: ua-cam.com/video/L4V15ZxIjBQ/v-deo.html

  • @sdl9258
    @sdl9258 2 роки тому

    Good

  • @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  Рік тому +1

      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

  • @normantam
    @normantam Рік тому

    Is there a way to customize this to export in landscape format? Thank you for the great video!

    • @saperis
      @saperis  Рік тому +1

      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

  • @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  Рік тому +1

      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.

  • @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.

  • @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.

  •  Рік тому

    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 роки тому +1

      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!

  • @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

  • @bachchuhaldar3783
    @bachchuhaldar3783 2 роки тому

    Great video 👍👍👍

    • @saperis
      @saperis  2 роки тому

      Glad you enjoyed it 😀

  • @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/

  • @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.

  • @Eatfoodswithpet
    @Eatfoodswithpet Рік тому

    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.

  • @joshuarmir
    @joshuarmir 10 місяців тому

    Hello, me again. Can I get the email from another cell value? I mean, the email will change everytime.

    • @saperis
      @saperis  9 місяців тому +1

      Sure. You are the creator of the script. So you decide how it works.

  • @aarondumapias6084
    @aarondumapias6084 Рік тому

    Hi, your video help me. Can I ask on how to automatically set it into landscape when converting into pdf?

    • @saperis
      @saperis  Рік тому +1

      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

  • @andreaguerri.educational
    @andreaguerri.educational 2 роки тому

    Sempre brava!

  • @Carnediporco
    @Carnediporco 2 роки тому +1

    i need to export only one sheet in a multi sheet document, how can i do ?

    • @saperis
      @saperis  2 роки тому +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

  • @ZborTuryst
    @ZborTuryst 10 днів тому

    😀What if we have 40 recipients?

  • @nutricaosaquarema1102
    @nutricaosaquarema1102 Рік тому

    Very good. There is a way to save only some sheets from a file?

    • @saperis
      @saperis  Рік тому +1

      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

  • @seamllc2511
    @seamllc2511 2 роки тому

    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  2 роки тому

      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 2 роки тому

      @@saperis Yes, I'm looking to see what that script is. But this got me off to the right start. Thank you!

  • @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.

  • @dyoncreab6761
    @dyoncreab6761 9 місяців тому

    hi good day,,, how to make a print button and preview using spreadsheet ,, thanks

    • @saperis
      @saperis  9 місяців тому

      Check this video to find out how you can add such a button: ua-cam.com/video/Xd56y8GZbIM/v-deo.html

  • @gauravkandal
    @gauravkandal 2 роки тому

    Thank you so much.
    Please guide how can we send single sheet from workbook.

    • @saperis
      @saperis  2 роки тому +1

      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 роки тому +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: ua-cam.com/video/5S7laJS9meU/v-deo.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 роки тому +1

      @@sirhenrymondeo Yes this how we are doing !!

  • @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()

  • @bibin2195
    @bibin2195 Рік тому +1

    How to send Excel like this

    • @saperis
      @saperis  Рік тому

      Check this tutorial: spreadsheet.dev/comprehensive-guide-export-google-sheets-to-pdf-excel-csv-apps-script

  • @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 роки тому +1

      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: ua-cam.com/video/UiZYy-146_0/v-deo.html

  • @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

  • @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.

  • @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: ua-cam.com/video/L4V15ZxIjBQ/v-deo.html

  • @JishiiCreations
    @JishiiCreations 11 місяців тому

    I want to convert Pdf in Landscape

    • @saperis
      @saperis  11 місяців тому

      I'd check Stackoverflow to see if you can find a code snippet there. I don't have one at hand myself.

  • @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

  • @ggbin8092
    @ggbin8092 Місяць тому

    How to export as image

  • @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.

  • @traviswarner3934
    @traviswarner3934 2 роки тому

    How can you send just one worksheet of a workbook?

    • @saperis
      @saperis  2 роки тому

      Have a look at this tutorial: xfanatical.com/blog/print-google-sheet-as-pdf-using-apps-script/

  • @HRArchtech-fb8hk
    @HRArchtech-fb8hk 11 місяців тому

    Mam if I need next month then what to do

    • @saperis
      @saperis  11 місяців тому

      I guess you export it next month?

    • @HRArchtech-fb8hk
      @HRArchtech-fb8hk 11 місяців тому

      @@saperis I want to do it for salary slip

    • @HRArchtech-fb8hk
      @HRArchtech-fb8hk 10 місяців тому

      hello mam pls reply

  • @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
      🙏

  • @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.

  • @surveilanspuskesmascimarag9937

    How can I print 2 pages?

    • @saperis
      @saperis  Рік тому +1

      You can't print with Apps Script as it doesn't have a way to connect to your computer or printer.

    • @surveilanspuskesmascimarag9937
      @surveilanspuskesmascimarag9937 Рік тому

      @@saperis I mean how do I export to pdf but from specified sheet and want 2 pages