How to Connect Excel to PostgreSQL

Excel is a widely used platform across all skill levels and is known for its user-friendly data processing capabilities. One of its most sought-after features is the ability to load data directly into Excel from various sources, such as PostgreSQL databases. Here, Devart Excel Add-ins offer a powerful and convenient solution with a variety of dedicated add-ins for direct connections to specific data sources.

The specialized add-in allows users to connect Excel to PostgreSQL, select specific data to retrieve, manage the imported data within Excel, and even update the data source directly from the spreadsheet. Let us see how to use this PostgreSQL Excel connector in work and make the most of its capabilities.

Configure connection to PostgreSQL from Excel

Ensure your system meets the requirements, including the correct version of Microsoft Excel.

Next, download and install the Excel Add-in for PostgreSQL. Once installed, a new Devart tab will appear in the Excel toolbar, allowing you to establish a PostgreSQL connection and manage all data-related operations directly from Excel.

To start work, click Get Data. The Import Data Wizard opens.

Devart tab in Excel

The Devart tab is automatically added after successfully installing the Devart Add-in. If it doesn't appear immediately, restart Excel and navigate to File > Options > Add-ins to confirm that add-ins are enabled.

Select the PostgreSQL database as the source.

Select PostgreSQL as source

You will then be prompted to enter the following PostgreSQL connection parameters:

  • Host - the name or IP address of the computer running the PostgreSQL server
  • Port - the port number used to connect to the PostgreSQL server
  • User ID - your PostgreSQL username
  • Password - your PostgreSQL password
  • Database - the name of the database you want to connect to from Excel
  • Schema - the PostgreSQL schema containing the target database

You can optionally configure additional parameters:

Allow saving add-in-specific data in Excel worksheet - сlear this checkbox if you don't want to save add-in-specific data, such as connections and queries, in the Excel worksheet. However, you will need to re-enter the PostgreSQL connection details each time you reload or save modified data in the database.

Allow saving connection string in Excel worksheet - сlear this checkbox to avoid storing connection details in the Excel file. If unchecked, you will need to re-enter connection parameters to load PostgreSQL data or upload data from Excel to PostgreSQL.

Allow saving password - it is recommended to clear this checkbox to avoid storing sensitive information, like passwords, in the Excel workbook.

Allow reuse connection in Excel - select this checkbox to reuse the connection details across other Excel sheets.

Click Test Connection to verify that all details are correct.

View parameters and test connection

If additional connection details are required, click Advanced at the bottom of the wizard and specify the necessary parameters. The Connection Editor window will display the PostgreSQL connection strings, which you can save and reuse later.

Configure advanced connection parameters

Click Next to proceed, and you can start the Excel PostgreSQL import process.

Import data from PostgreSQL into Excel

Once the connection to your PostgreSQL database is successfully established, you can load PostgreSQL data directly into the Excel workbook.

1. In the Import Data Wizard, select the table to import data into Excel from it.

Select PostgreSQL table

2. Switch to the Visual Query Builder tab and select the particular column or columns. On the right pane, you can see the basic query used to load PostgreSQL data into Excel.

Select data portion from PostgreSQL table

3. Also, you can edit the standard query or write a new custom query for the PostgreSQL export to Excel case according to your specific work scenario.

Query editor

4. Preview the data to be imported from the PostgreSQL database and adjust the Excel PostgreSQL import options. You can either create a new worksheet for the imported data or replace existing data with the imported data. It is recommended to create a new sheet to avoid accidental deleting of the necessary data.

Preview PostgreSQL data in Excel add-in

Click Finish, and the data import will start immediately.

Live edit PostgreSQL data in Excel

When the data from your PostgreSQL database table is present in the Excel worksheet, you can work with it in the same way as with any other data portion in Excel.

By default, the data is imported as read-only. Click Edit Mode on the toolbar, and it will define the editable data.

Edit mode to work with data

You can modify separate cells, add new rows, delete some data, or insert new records in the usual manner. All changes are highlighted with different colors which you can customize in Options > Appearance.

Upload Excel data

The Devart Excel Add-in for PostgreSQL provides the Excel to PostgreSQL export option so that you can upload all changes back to the database. The Devart tab toolbar includes the Commit and the Rollback buttons.

  • To upload the modified data back to PostgreSQL, click Commit.
  • To cancel the upload Excel into PostgreSQL action, click Rollback.

Commit or revert changes

After you upload Excel to PostgreSQL, you can check the data directly in your database in the usual way, using your favored tools.

Conclusion

Microsoft Excel remains a popular choice for data management, offering robust built-in functionality that can be further enhanced with tools like Devart Excel Add-ins. By integrating these add-ins, you can significantly improve your workflows. They enable quick and easy connections to various data sources, including major databases and popular cloud platforms, letting you import data directly into Excel, and upload it back to PostgreSQL or other supported platforms.

You can download and install the specialized Excel Add-in for PostgreSQL, or opt for the Devart Universal Pack, a comprehensive set of Excel add-ins, that ensures smooth and reliable connections and data import and export between Excel and over 20 popular data sources, for your data management processes.

Excel Add-in Universal Pack

Use full power of Excel with your cloud or database data