GitHub - RusselWebber/xlDuckDb: Use DuckDB within Excel with the xlDuckDb addin

Open original

xlDuckDb is an Excel add-in that lets you write DuckDB SQL queries directly in spreadsheet cells and get results back as normal Excel data. You can query Excel ranges, JSON files, CSV files, Parquet files, and even remote data on HTTPS or AWS S3.

  • The add-in works with Excel ranges, named ranges, and tables using simple syntax like =DuckDbQuery(A27,,A1:E25), plus you can query multiple ranges in a single query by passing them as separate arguments.
  • DuckDB handles messy data formats automatically—it auto-detects CSV delimiters and data types, extracts nested JSON with JSONPath syntax, and efficiently queries large Parquet files that don't fit in memory.
  • You can join data across multiple file types in one SQL query (e.g., combining JSON and CSV data with a CTE and INNER JOIN), making it possible to correlate disparate datasets without leaving Excel.

xlDuckDb is an Excel add-in that lets you run DuckDB SQL queries directly within spreadsheets, with results appearing as regular cells. You download the .xll file, unblock it in Windows, and double-click to register the DuckDbQuery function. It requires 64-bit Excel 365 (post-September 2018) and .Net 8.0 runtime. The core feature is querying Excel ranges, named ranges, and tables using standard SQL syntax — you just pass the range as an argument to DuckDbQuery, and it treats the data like a database table. You can also query multiple ranges in a single query by passing them as additional arguments and referencing them as xlRange[1], xlRange[2], etc. Beyond Excel data, the add-in taps into DuckDB's ability to query external files directly. JSON files work particularly well — DuckDB handles nested structures through JSONPath syntax (using the `->>'$[0].category'` notation, for example) and can extract data from complex documents like the Nobel Prize laureate dataset. CSV files are handled with automatic delimiter and type detection. Parquet files, designed for efficient columnar storage, can be queried even when they're too large to fit in memory. You can also query data stored remotely on HTTPS or AWS S3, making it possible to pull holdings data from duckdb.org or attach to databases in cloud storage. The real power emerges when combining sources. You can write a single SQL query that joins JSON data with CSV results, uses CTEs to transform one dataset, and then pivots the output for analysis. The article walks through practical examples — finding countries with the most Nobel laureates and cross-referencing their sales data, or analyzing Titanic passenger survival rates by cabin class and age. This transforms Excel from a static spreadsheet tool into something that can handle serious data work without leaving the familiar interface.

Ask about this article