Question

How do I export the first worksheet in a Google Sheet as a PDF

  • 22 October 2023
  • 5 replies
  • 111 views

Userlevel 1

I have a Google Sheet the contains three worksheets. The 2nd and 3rd worksheet is used to look up values for the first worksheet. How do I generate a PDF for JUST the first worksheet? 

I have done the find a file Google Drive action but this provides a pdf of ALL THREE worksheet.


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

5 replies

Userlevel 7
Badge +14

Hi @Crazy8s 

Good question.

Perhaps hide the 2 lookup worksheets.

Help topic:

 

Userlevel 1

@Troy Tessalone can you do this via Zapier as well? The sheet is created each time based on a template. 

 

 

 

Userlevel 7
Badge +14

@Crazy8s 

Step 7 will return a GDrive File ID and the GDrive File Name for the GSheet.

You can use the GDrive File Name to search for the File in Step 13.

Otherwise, you can use the GDrive File ID as part of a dynamic direct link to get the CSV version of the GSheet.

Userlevel 1

@Troy Tessalone I am asking specifically on how to hide the worksheets. Is that possible within Zapier?

Userlevel 7
Badge +14

@Crazy8s 

Why not manually hide the 2 worksheet tabs on the GSheet template being copied?

 

Yes, should be doable via the GSheets API: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate

 

Feedback from ChatGPT:

 

To hide a worksheet tab in Google Sheets using only HTTP REST requests without external libraries, you can use a tool like curl. You'll need to interact with the Google Sheets API directly. Here's an example of how to do this:

  1. Obtain your Google Sheets API credentials and API Key. You can follow Google's documentation to create a project in the Google Cloud Console and enable the Google Sheets API.

  2. Set your API key and spreadsheet ID:

API_KEY="YOUR_API_KEY" SPREADSHEET_ID="YOUR_SPREADSHEET_ID" SHEET_NAME="Sheet1" # Change to the name of your sheet
  1. Use curl to make an HTTP POST request to hide the sheet:
curl -X POST \ "https://sheets.googleapis.com/v4/spreadsheets/$SPREADSHEET_ID:batchUpdate" \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "requests": [ { "updateSheetProperties": { "properties": { "title": "'"$SHEET_NAME"'" }, "fields": "hidden" } } ] }'

Replace "YOUR_API_KEY", "YOUR_SPREADSHEET_ID", and "Sheet1" with your actual API key, spreadsheet ID, and sheet name.

This curl command sends an HTTP POST request to the Google Sheets API, which will hide the specified sheet in your Google Sheets document.