Export LibreOffice Base Queries to Spreadsheets

Exporting query results from LibreOffice Base into spreadsheets can be accomplished using several built-in features, native integration tools, and automation scripts. Because LibreOffice Base is tightly integrated with the rest of the LibreOffice suite, users can transfer query outputs directly into LibreOffice Calc or export them to third-party spreadsheet formats like Microsoft Excel without relying heavily on complex third-party software.

1. The LibreOffice Calc Data Sources Panel (F4 Tool)

The most direct and seamless built-in tool for pulling Base query results into a spreadsheet is the Data Sources viewer in LibreOffice Calc. * How it works: Open LibreOffice Calc and press F4 (or navigate to View > Data Sources). The registered Base databases will appear in a pane above the spreadsheet. * Exporting: Expand your database, select Queries, click the desired query, and drag the entire dataset or use the Data to Text icon to drop the live query results directly into your active sheet.

2. Drag-and-Drop from the Base Query View

For quick, manual transfers, Base supports direct drag-and-drop actions into open Calc spreadsheets. * How it works: Open both LibreOffice Base and a new Calc spreadsheet side-by-side. * Exporting: In Base, click on the Queries tab, then click and drag the query name directly onto an empty cell in the Calc window. Calc immediately generates a table containing the complete query results.

3. Copy-Paste / Table Clipboard Export

If you need specific records or want to paste directly into other spreadsheet tools like Microsoft Excel or Google Sheets: * How it works: Double-click the query in Base to open the results table. * Exporting: Click the empty box in the upper-left corner of the data grid to select all rows, press Ctrl + C (or Cmd + C), and paste (Ctrl + V) directly into your target spreadsheet application.

4. LibreOffice Basic and Python Macros

For scheduled or recurring exports, you can write internal scripts using LibreOffice Basic or Python via the UNO (Universal Network Objects) API. * How it works: Macros can execute SQL queries directly against the Base data engine and populate cell ranges in Calc automatically. * Output: These scripts can be assigned to buttons inside Base forms or triggered from the command line to generate .ods or .csv files automatically.

5. Direct Database Connectors (ODBC / JDBC)

If your LibreOffice Base file connects to an external database backend (such as MySQL, PostgreSQL, MariaDB, or SQLite), you can bypass Base entirely to extract query results into spreadsheets. * How it works: Connect Calc or Excel directly to the underlying database engine using standard ODBC or JDBC drivers. * Exporting: Execute your SQL query from within the spreadsheet’s external data connection wizard to import live data directly into the worksheet.