Export Postgres Data to XLS File Using n8n Automation

This workflow automates exporting data from a PostgreSQL database into an XLS spreadsheet file. It saves time and eliminates manual errors for database managers and analysts needing quick data exports.
postgres
spreadsheetFile
writeBinaryFile
Workflow Identifier: 1560
NODES in Use: Postgres, Spreadsheet File, Write Binary File
Export Postgres data to XLS with n8n

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What This Workflow Does

This workflow gets data from a PostgreSQL database and turns it into an Excel file automatically. It solves the problem of wasting time copying and pasting product names and EAN codes each week. The outcome is a file named “spreadsheet.xls” saved on your computer or server, ready to share with others.

The workflow runs a SQL query, changes the data into a spreadsheet, and saves it to a file without manual work.


Who Should Use This Workflow

This is for anyone who needs to export product data from a PostgreSQL database often. It helps users who want to stop doing slow, repeat manual exports and reduce mistakes.

The workflow is useful for teams that must deliver fresh product lists regularly in Excel format.


Tools and Services Used

  • PostgreSQL Database: Holds product data like names and EAN codes.
  • n8n Automation Tool: Runs the workflow to get data and save files.
  • Spreadsheet File Node in n8n: Changes JSON data to spreadsheet format.
  • Write Binary File Node in n8n: Saves the spreadsheet as an XLS file on disk.

If using custom environments, see self-host n8n for options to run n8n securely with file saving ability.


Inputs, Processing, and Output

Inputs

  • Valid PostgreSQL access credentials (host, port, database, user, password).
  • Correct SQL query: SELECT name, ean FROM product.

Processing Steps

  • Run SQL Query: The Postgres node fetches product names and EAN codes.
  • Convert to Spreadsheet: The Spreadsheet File node turns database output into spreadsheet binary.
  • Save File: The Write Binary File node writes the spreadsheet as “spreadsheet.xls” on local disk or server.

Output

The final file “spreadsheet.xls” contains product names and EANs, ready for distribution or analysis.


Beginner Step-by-Step: How to Use This Workflow in n8n

Step 1: Import Workflow

  1. Download the workflow using the Download button on this page.
  2. Inside your n8n editor, click “Import from File” and select the downloaded file.

Step 2: Configure Credentials

  1. Add your PostgreSQL credentials (host, port, database name, user, password) to the Postgres node.
  2. Update any table or field names in the SQL query if needed.

Step 3: Adjust File Saving (Optional)

  1. Change the file path or name in the Write Binary File node if you want another location or filename.

Step 4: Test and Activate

  1. Run the workflow once manually to check it works and the XLS file appears with correct data.
  2. If the test is successful, activate the workflow for regular use.

Follow these steps to get the workflow running quickly without building nodes by hand.


Common Issues and Solutions

  • Error: “permission denied for relation product” when running query.
    Cause: PostgreSQL user lacks permission.
    Fix: Run GRANT SELECT ON product TO your_user; in database.
  • Error: File does not save successfully.
    Cause: No write access on folder for n8n.
    Fix: Allow write permission for n8n user or change file path to writable directory.

Customization Ideas

  • Modify SQL query in Postgres node to export different data. Example: SELECT id, price FROM product.
  • Change the exported filename in Write Binary File node, like “monthly_product_report.xls” or add dynamic timestamps using JavaScript expressions.
  • Set a different file path to save the spreadsheet elsewhere on your system, such as /tmp/spreadsheet.xls.

Summary

✓ Saves time by automating export of product data from PostgreSQL to Excel.
✓ Avoids human error from manual copying and formatting.
✓ Provides a ready XLS file for quick sharing.
✓ Easy setup and testing inside n8n.
→ Enables regular, accurate product data reports with little effort.


Export Postgres data to XLS with n8n

Visit through Desktop to Interact with the Workflow.

Promoted by BULDRR AI

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.