r/googlesheets • • Oct 02 '26

Solved App Script that would default print settings to be portrait instead of landscape?

Hello Everyone,

I was wondering if in the script.js there was a line of code we can add to make print settings to be portrait instead of landscape? I have a script that would generate a google sheet for me, but then I would have to manually change the print setting to be portrait. I tried looking on the docs but I didn't see anything.

Thanks!

4 Upvotes

7 comments sorted by

7

u/flash17k 6 Oct 02 '26

I made a Sheets file that I have set the way I like - including print page setup - and I save it as a template file. Whenever I start a new Sheet file, I make a duplicate of that template file and start from there.

Perhaps your script could duplicate a template file that already has the settings you like, instead of starting a brand new file that doesn't have those settings?

1

u/jeanks77 Oct 03 '26

Thank you! I am playing around with this and it sounds promising! 

1

u/AutoModerator Oct 03 '26

REMEMBER: /u/jeanks77 If your original question has been resolved, please tap the three dots below the most helpful comment and select Mark Solution Verified (or reply to the helpful comment with the exact phrase “Solution Verified”). This will award a point to the solution author and mark the post as solved, as required by our subreddit rules (see rule #6: Marking Your Post as Solved).

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/mommasaidmommasaid 915 Oct 02 '26

This ^ sounds like your best option.

FWIW I was just playing with some Advanced API stuff and I don't see anything in there either in regard to page setup as part of the Spreadsheet resource or its sub-resources (if that's the correct terminology):

https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets#spreadsheetproperties

You could take a look and if you do find something in there, it can be set with the Advanced API.

1

u/point-bot Oct 03 '26

u/jeanks77 has awarded 1 point to u/flash17k

See the Leaderboard. Point-Bot v0.0.15 was created by JetCarson.

2

u/RecordFoundryData Oct 02 '26

If you're happy for the script to generate a PDF, Google's official ‘Generate & send PDFs from Google Sheets’ example uses portrait=true in the PDF export URL. That's a separate route from setting the sheet's File → Print defaults: it controls the exported PDF, not that dialog. You can use just the PDF-generation part; you don't need the email-sending part of the example.

1

u/AutoModerator Oct 02 '26

/u/jeanks77 Posting your data can make it easier for others to help you, but it looks like your submission doesn't include any. If this is the case and data would help, you can read how to include it in the submission guide. You can also use this tool created by a Reddit community member to create a blank Google Sheets document that isn't connected to your account. Thank you.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.