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
xlsxwriter. Cast columns of those types toVARCHARprior to creating thexlsxfile.
See Also
DuckDB can also import Excel files. For additional details, see the spatial extension page and the GDAL XLSX driver page.
© Copyright 2018–2024 Stichting DuckDB Foundation
Licensed under the MIT License.
https://duckdb.org/docs/guides/file_formats/excel_export.html