Connecting and importing data

To import data from MySQL into Excel, you must create a connection to MySQL or use an existing one.

Creating a connection and importing data

To connect to MySQL and import data:

1. On the Excel ribbon, open the Devart tab and click Get Data. The Connection Editor dialog box opens.

Connection Editor.

2. In the Connection Editor dialog box, select MySQL from the Data Source list. Alternatively, select an existing saved connection.

3. Specify the required connection parameters.

The available parameters depend on the selected data source. For details about MySQL connection parameters, see MySQL connection settings.

To verify that the connection works, click Test Connection.

To configure additional connection parameters, click Advanced. The generated connection string appears at the bottom of the Connection Editor dialog box.

Connection Editor.

4. Optionally, configure the following settings to save and reuse connection information:

  • Allow saving add-in specific data in Excel worksheet - Saves add-in data, such as queries and connection information, in the workbook.
  • Allow saving connection string in Excel worksheet - Saves the connection string in the workbook.
  • Allow saving password - Saves the connection password together with the connection information.

  • Allow reuse connection in Excel - Saves the connection on your computer so you can reuse it in other Excel workbooks. Specify a unique name for the connection.

Note

Avoid saving passwords and other security information in workbooks that you plan to share, as this may expose your credentials to other users.

You can also configure these settings later in the Security settings.

5. After configuring the connection, click Next to open the Query Builder.

Select the MySQL object and columns you want to import. You can also apply filters and specify the sort order.

For more information, see Visual Query Builder.

Alternatively, open the SQL Query tab and enter a SELECT statement to retrieve the required data.

Visual Query Builder.

6. Click Next to open the Preview window.

Review the query results and configure the options for importing data into the Excel worksheet. For details, see Preview and import options.

Import Preview.

7. Click Finish to import the data.

The imported data appears in the active Excel worksheet.

Imported data in an Excel worksheet.

You can now work with the imported data in Excel and, if necessary, save changes back to MySQL.

Preview and import options

On the Preview page of the Import Data Wizard, review the query results and select where to import the data.

Option Description
Use the first … rows to preview query data Specifies the number of rows to display in the preview. The default is 10. This setting does not limit the number of imported rows.
Row count Displays the number of rows returned by the query, or Unknown if the count cannot be determined.
New worksheet Imports data into a new worksheet. Enter a unique, nonempty worksheet name. By default, the name consists of a prefix followed by the main table name, or Query for a custom SQL query. You can change the prefix on the Appearance page of the Options dialog box.
Replace data on existing worksheet Imports data into the selected worksheet, replacing its contents. The list includes only visible worksheets where Edit Mode is inactive. This option is unavailable if no such worksheets exist.

Changing the query of imported data

If the active worksheet contains imported data, clicking Get Data opens the Import Data Wizard with its existing connection and query settings. You can then modify the query and reimport the data.

To change the query of imported data:

1. Select the worksheet that contains the imported data.

2. On the Devart tab, click Get Data.

3. Modify the connection parameters and query as needed, then click Next.

4. On the Preview page, review the results and click Finish.

Note

If another table or user-entered data occupies the same columns as the imported table, the add-in warns you that this content will be lost if you continue.

To import data from a different source or object into a new worksheet, select a worksheet without imported data before clicking Get Data.

Managing connections

You can create, edit, rename, and delete saved connections.

To manage connections, open the Devart tab on the Excel ribbon and click Manage Connections. The Connections dialog box opens, displaying the available data sources and saved connections.

You can perform the following actions:

  • Create a connection: Right-click the data source and select New connection, or press Insert. Configure the connection as described in Creating a connection and importing data.
  • Edit a connection: Double-click the connection, or right-click it and select Edit, to open the Connection Editor dialog box and modify its parameters.
  • Rename a connection: Right-click the connection and select Rename, or press F2.
  • Delete a connection: Select the connection and press Delete, or right-click it and select Delete.