How to Generate Mass Invoices in LibreOffice Writer
Generating mass invoices in LibreOffice Writer is accomplished by integrating external database records into a standardized invoice template using Mail Merge and database field insertion techniques. By connecting a data source—such as a LibreOffice Calc spreadsheet, CSV file, or SQL database—users can map dynamic fields like customer details, invoice numbers, line items, and totals directly into a Writer document. This guide explains the core database field insertion methods required to automate bulk invoice creation, batch printing, and individual PDF generation in LibreOffice.
1. Connecting the Data Source
Before inserting fields, LibreOffice Writer must be connected to your data source:
- Open LibreOffice Writer and press
F4(or go to View > Data Sources) to display the Data Source Explorer. - If your database or spreadsheet is not listed, register it by navigating to Tools > Options > LibreOffice Base > Databases.
- Click New…, browse to select your file (e.g.,
.ods,.csv,.db), assign a registered name, and click OK.
Your database tables and queries will now appear in the Data Source pane above the document workspace.
2. Drag-and-Drop Field Insertion
The fastest method for placing database fields into your invoice layout is direct drag-and-drop:
- In the Data Source Explorer (
F4), expand your registered database and select the specific table or query containing your invoice data. - Click and hold the column header of the desired field (e.g.,
Customer_Name,Billing_Address,Invoice_Total). - Drag the header directly into the target position or table cell inside your invoice template.
- Release the mouse button. The field will appear enclosed in angle
brackets, such as
<Customer_Name>.
3. Inserting Fields via the Fields Dialog
For greater control over formatting and field types:
- Place your cursor where the data should appear.
- Navigate to Insert > Field > More Fields… (or
press
Ctrl + F2). - Select the Database tab.
- In the Type column, select Mail merge fields.
- In the Database selection pane, expand your database, choose the table, and select the field to insert.
- Click Insert and close the dialog.
4. Handling Multi-Line Invoices and Record Navigation
Standard Mail Merge creates one document page per database row. For invoices with multiple line items per customer, two techniques are used:
- Next Record Field: To force LibreOffice to pull the next row within the same page (useful for flat tables with consecutive line items), insert a Next record field via Insert > Field > More Fields > Database > Next record.
- Base Report Builder: For complex master-detail relationships (one invoice header with variable multiple line items), building the invoice via the Report feature in LibreOffice Base using grouped SQL queries provides superior automated grouping and summing compared to standard Writer Mail Merge.
5. Outputting the Mass Invoices
Once the template fields are arranged:
- Go to File > Print.
- A prompt will appear stating: “Your document contains address database fields. Do you want to print a form letter?” Click Yes.
- In the Mail Merge dialog, select the records you wish to process (all or a specific range).
- Choose your output format:
- Printer: Sends all generated invoices directly to a physical or virtual printer.
- File: Generates the batch output. You can save all
invoices as a single combined document or select Save as
individual documents and assign a dynamic file path using an
invoice number field (e.g.,
Invoice_<ID>.pdf).