Robert Miller
Robert Miller

Reputation: 23

App Script Hyperlink Download PDF

Is there a way via a hyperlink to only create a PDF of a specific sheet using a hyperlink formula? If I do not hide the sheet it will also add the second sheet to the pdf export. I tried using GID in the URL, but that only reopened the current PDF or exported it as CSV. This is created dynamically via script when the sheet opens.

Upvotes: 0

Views: 381

Answers (1)

ReyAnthonyRenacia
ReyAnthonyRenacia

Reputation: 17613

Try this:

Let's say you want to publish only Sheet 1 as PDF of your spreadsheet file:

  1. In google sheets, go to File and choose Publish to the Web.
  2. Under Link tab, choose Sheet 1 and choose PDF Document format.
  3. Copy the link and run it on the browser. It will download Sheet 1 only.

Notice also the URI format:

https://docs.google.com/spreadsheets/d/e/2PACX-1vS-fqXA_S5rj18aVSe6bj1HA2AUYCaYr2BNLbN_w1a_B77QlgnRKB5y3QUBTv0wIu6KxkOm_qq71m6H/pub?gid=0&single=true&output=pdf

If you want to publish a different sheet as PDF, copy the 'gid' of that sheet and assign it to the 'gid' value in the link.

Upvotes: 1

Related Questions