What This Workflow Does
This n8n workflow solves the common business challenge of regularly extracting data from SQL databases into Excel format. Many teams waste hours each week manually exporting query results, reformatting data, and distributing reports. This automation eliminates that repetitive work while ensuring consistency and accuracy.
The workflow connects to your SQL database, executes a predefined query, transforms the results into Excel format, and delivers the spreadsheet to your chosen destination. It can run on schedule or be triggered by specific events, providing fresh data exactly when needed without manual intervention.
How It Works
1. Database Connection
The workflow begins by establishing a secure connection to your SQL database using credentials you provide. It supports all major SQL variants including MySQL, PostgreSQL, and SQL Server.
2. Query Execution
Your predefined SQL query runs against the connected database. The workflow can handle complex queries with joins, subqueries, and aggregations just like manual exports.
3. Data Transformation
Results are processed to ensure proper Excel compatibility. This includes handling NULL values, date formatting, and special characters that might cause issues in Excel.
4. Excel Generation
The transformed data is packaged into a proper Excel file (.xlsx format) with optional formatting like column widths, headers, and number formatting.
5. Delivery
The final Excel file can be sent via email, saved to cloud storage (Google Drive, Dropbox), or delivered through other integrated services.
Who This Is For
This workflow benefits any business or team that regularly extracts data from databases for analysis, reporting, or sharing:
- Financial teams needing daily transaction reports
- Marketing teams analyzing customer data
- Operations teams tracking inventory or logistics
- IT teams providing data extracts to other departments
- Consultants preparing client reports from database systems
What You'll Need
- Access to an n8n instance (cloud or self-hosted)
- Database credentials with read permissions
- The SQL query you want to automate
- A destination for the Excel files (email, cloud storage, etc.)
Quick Setup Guide
- Download the JSON template file
- Import it into your n8n instance
- Configure the SQL database connection with your credentials
- Paste your SQL query into the workflow
- Set up the Excel output destination
- Test the workflow with a manual trigger
- Schedule regular runs or set up triggers as needed
Pro tip: For recurring reports, add a timestamp to the Excel filename to avoid overwriting previous versions.
Key Benefits
Save 5-30 minutes per report by eliminating manual export processes. What used to be a daily chore becomes an automatic background task.
Eliminate human errors in data transfers. Automated workflows don't make copy-paste mistakes or forget steps in the export process.
Ensure consistent formatting across all reports. Every Excel file follows the same structure without manual tweaking.
Deliver reports on schedule even when team members are unavailable. Automation doesn't take vacations or sick days.
Scale reporting capabilities without adding staff. Generate more frequent or complex reports without increasing workload.