Search Shortcut cmd + k | ctrl + k
Search cmd+k ctrl+k
0.10 (stable)
Excel Export

Installing the Extension

To export the data from a table to an Excel file, install and load the spatial extension. This is only needed once per DuckDB connection.

INSTALL spatial;
LOAD spatial;

Exporting Excel Sheets

Then use the COPY statement. The file will contain one worksheet with the same name as the file, but without the .xlsx extension.

COPY tbl TO 'output.xlsx' WITH (FORMAT GDAL, DRIVER 'xlsx');

The result of a query can also be directly exported to an Excel file.

COPY (SELECT * FROM tbl) TO 'output.xlsx' WITH (FORMAT GDAL, DRIVER 'xlsx');

Dates and timestamps are currently not supported by the xlsx writer. Cast columns of those types to VARCHAR prior to creating the xlsx file.

Warning The output file must not already exist.

See Also

DuckDB can also import Excel files. For additional details, see the spatial extension page and the GDAL XLSX driver page.

About this page

Last modified: 2024-05-23