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
- Download the workflow using the Download button on this page.
- Inside your n8n editor, click “Import from File” and select the downloaded file.
Step 2: Configure Credentials
- Add your PostgreSQL credentials (host, port, database name, user, password) to the Postgres node.
- Update any table or field names in the SQL query if needed.
Step 3: Adjust File Saving (Optional)
- Change the file path or name in the Write Binary File node if you want another location or filename.
Step 4: Test and Activate
- Run the workflow once manually to check it works and the XLS file appears with correct data.
- 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: RunGRANT 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.

