---
sidebar_position: 7
sidebar_label: Microsoft Excel
title: Connect MotherDuck to Excel
description: Load MotherDuck data into Excel using the DuckDB ODBC driver on Windows or export options for macOS.
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

Use Excel's 'Get Data' flow with the DuckDB ODBC driver to load MotherDuck data into Excel. This setup works well for recurring reporting, analysis, ad hoc SQL exploration, finance models, and operational dashboards without having to rely on exported CSVs.

<Tabs groupId="os-excel">
<TabItem value="wd" label="Windows" default>

## Before you start

To get started you'll need the following.

- Windows + Excel (ODBC is Windows-only for this flow)
- A MotherDuck access token (create one in the [MotherDuck token page](/key-tasks/authenticating-and-connecting-to-motherduck/authenticating-to-motherduck/#creating-an-access-token))
- Admin rights on your computer to install the ODBC driver

## Installation steps

### 1. Install the DuckDB ODBC driver

1. Download the latest DuckDB ODBC driver for Windows (amd64):
   - [duckdb_odbc-windows-amd64.zip](https://github.com/duckdb/duckdb-odbc/releases/latest/download/duckdb_odbc-windows-amd64.zip)
2. Extract the `.zip` file and run `odbc_install.exe` as Administrator (right click -> Run as administrator).

### 2. Configure the DuckDB System DSN

1. Open the ODBC Data Source Administrator:
   - 64-bit Excel: Start menu -> ODBC Data Sources (64-bit)
   - 32-bit Excel: Start menu -> ODBC Data Sources (32-bit)

![ODBC Data Sources in Windows](./img/ODBC-data-sources-windows.png)

2. Go to System DSN, select DuckDB, and click Configure. ![Select the DuckDB system DSN](./img/ODBC-data-source-duckdb.png)

3. Set Database to one of the following:
   - Recommended (scoped): `md:your_database_name`
   - Open scope: `md:` (allows access to any database)
4. Click OK to save.

![DuckDB ODBC configuration for MotherDuck](./img/ODBC-data-source-configuration.png)

### 3. Connect from Excel (Get Data)

1. In Excel, go to Data -> Get Data -> From Other Sources -> From ODBC.

![Excel Get Data menu](./img/getdata-excel.png)
2. Choose DuckDB from the DSN dropdown and click OK.

![From ODBC dialog in Excel](./img/from-ODBC-driver-excel.png)
3. On the credentials screen, choose Default or Custom and add this to the Connection string properties field:

   ```text
   motherduck_token=<YOUR_MOTHERDUCK_ACCESS_TOKEN>
   ```

![DuckDB ODBC driver installer](./img/ODBC-driver-excel.png)

4. Click Connect.

### 4. Load or transform data

Use the Navigator window to select tables and choose Load to bring data into Excel, or Transform Data to shape it in Power Query before loading.

</TabItem>
<TabItem value="mac" label="macOS">

## Excel ODBC on macOS

Direct ODBC connectivity between Excel and MotherDuck is **not currently supported on macOS** due to a driver incompatibility.

### Why it doesn't work

Excel on macOS uses the **iODBC** driver manager, but the DuckDB ODBC driver is built for **unixODBC**. These drivers are incompatible at the binary level. This is a [known issue](https://github.com/duckdb/duckdb-odbc/issues/40) being tracked by the DuckDB team.
If necessary, you can build this driver yourself.

### Alternatives for macOS users

#### Option 1: Export directly to Excel with DuckDB (CLI and drivers)

DuckDB has an [Excel extension](https://duckdb.org/docs/stable/core_extensions/excel) that can write `.xlsx` files directly. This works with DuckDB CLI or any DuckDB driver, but cannot be used in the MotherDuck UI as we cannot currently export `.xlsx` files to your local file system.

```sql
-- Connect to MotherDuck and export to Excel
ATTACH 'md:';
COPY (SELECT * FROM my_database.my_table) TO 'output.xlsx' WITH (FORMAT xlsx, HEADER true);
```

Or via command line:

```bash
duckdb -c "ATTACH 'md:'; COPY (SELECT * FROM my_database.my_table) TO 'output.xlsx' WITH (FORMAT xlsx, HEADER true);"
```

#### Option 2: Use the MotherDuck Web UI

Query your data in the [MotherDuck Web UI](https://app.motherduck.com) and export results:

1. Run your query in the MotherDuck UI
2. Click the download button to export as CSV
3. Open the CSV in Excel

#### Option 3: Export to CSV via DuckDB CLI

Use the DuckDB CLI to export query results to CSV:

```bash
duckdb -c "ATTACH 'md:'; COPY (SELECT * FROM my_database.my_table) TO 'output.csv' (HEADER, DELIMITER ',');"
```

</TabItem>
</Tabs>

## Tips

- If you change your MotherDuck token, update the connection string properties in Excel.
- If you use multiple databases, create separate DSNs (e.g., `DuckDB - analytics`, `DuckDB - finance`) with different `md:database` values.

## Troubleshooting

### How do I delete an existing MotherDuck connection in Excel?

1. In Excel, go to Data -> Queries & Connections.
2. Find the connection you want to remove, right click it, and choose Delete.

### How do I modify an existing MotherDuck connection?

1. In Excel, go to Data -> Queries & Connections.
2. Right click the connection and choose Properties.
3. Open the Definition tab and update the connection string (for example, update `motherduck_token=...`) and save.

If you don't see the Definition tab, use Data -> Get Data -> Data Source Settings, select your DuckDB connection, then choose Change Source or Edit Permissions as needed.
