Generate Documents With Line Items: Tables That Expand Automatically

Summarize with AI

Use this feature when each document needs a table that repeats for every row of related data: invoices with line items, order confirmations with products, school reports with subjects, payslips with earnings components, and so on.

What is a line items document?

Most documents have a fixed structure: fill in a few fields and you’re done. But some documents need a table that grows depending on how many related items belong to each record.

A few examples:

  • An invoice for Acme Corp has 4 line items. An invoice for Globex has 9. Both use the same template; the table expands to fit.
  • A purchase order lists every product being ordered, with quantity and price per line.
  • A payslip lists every earnings or deduction component for that pay period.
  • A school report lists every subject a student is enrolled in, with their grade.
  • A meeting agenda lists every agenda item with the presenter and time slot.

You define the template once. ActiveMerge generates every document with the right number of rows.

What can you use this for?

Industry Document Repeating rows
Finance & Accounting Invoices, quotes, credit notes Products/services, taxes, discounts
Logistics Packing lists, delivery notes, BOLs Items, quantities, SKUs, weights
HR & Payroll Payslips, offer letters with benefits Earnings, deductions, allowances
Education Student reports, transcripts, certificates Subjects, grades, competencies
Legal Engagement letters, schedules of work Tasks, milestones, fees
Events Agendas, run-of-show sheets, itineraries Sessions, speakers, time slots
Sales Proposals, order confirmations, quotes Products, pricing tiers, add-ons
Healthcare Discharge summaries, referral letters Diagnoses, medications, procedures
Construction Progress claims, variation orders Work items, rates, quantities
Retail Receipts, statements, loyalty summaries Transactions, points, items

How it works

You set up two things:

  1. A Word template with a table that has one data row using {{item.ColumnName}} placeholders
  2. A data source: either an Excel file with two sheets, or an Airtable table with linked records

ActiveMerge links the data together and generates one document per main record, with the line-items table expanded to include all the matching rows.

Option A: Excel (two sheets)

Sheet 1: Main data

One row per document. These columns fill your regular {Placeholder} fields.

InvoiceNo Client Date Due Date Total
INV-001 Acme Corp 2026-05-09 2026-06-09 $1,510.00
INV-002 Globex Ltd 2026-05-10 2026-06-10 $600.00

Sheet 2: Line items

Multiple rows per document, linked to Sheet 1 by a shared column.

InvoiceNo Description Qty Unit Price Amount
INV-001 Web Design 1 $1,500.00 $1,500.00
INV-001 Domain Registration 1 $10.00 $10.00
INV-002 Consulting 3 $200.00 $600.00

The join column (InvoiceNo here) must appear in both sheets with the same name and matching values. ActiveMerge detects it automatically, no configuration needed.

Rules for Sheet 2

  • The first row must be column headers
  • Spaces in column names become underscores in templates (Unit Price becomes Unit_Price)
  • Rows with no join key value are skipped
  • A document with no matching line items generates with an empty table

Option B: Airtable (linked records)

If your data lives in Airtable, you don’t need a separate sheet. Use a linked record field, Airtable’s built-in way to relate rows across tables.

Setup

  1. In your Airtable base, create two tables: one for the main records (e.g. Invoices) and one for the line items (e.g. Invoice Items).
  2. In the Invoices table, add a Link to another record field pointing to Invoice Items.
  3. Populate the linked field by connecting each invoice to its items.

Invoices table:

Invoice No Client Date Total Items (linked)
INV-001 Acme Corp 2026-05-09 $1,510.00 Web Design, Domain Name
INV-002 Globex 2026-05-10 $600.00 Consulting

Invoice Items table:

Description Qty Unit Price Amount
Web Design 1 $1,500.00 $1,500.00
Domain Registration 1 $10.00 $10.00
Consulting 3 $200.00 $600.00

In ActiveMerge

When you connect your Airtable table in Step 2, any Link to another record fields appear in the Line Items section of the field mapping screen. Select the linked field you want to use as the source for your repeating table.

ActiveMerge fetches all the linked records and groups them under the correct parent document.

Setting up your Word template

In your .docx template, create a table with a plain-text header row (appears once) and one data row with {{item.ColumnName}} placeholders (this row repeats).

Invoice Number: {InvoiceNo}
Client: {Client}
Date: {Date}

+----------------------+-----+------------+-----------+
| Description          | Qty | Unit Price | Amount    |
+----------------------+-----+------------+-----------+
| {{item.Description}} | {{item.Qty}} | {{item.Unit_Price}} | {{item.Amount}} |
+----------------------+-----+------------+-----------+

Total: {Total}

Use double curly braces {{ }} for line item placeholders, and single braces { } for main-record placeholders. Both work in the same template.

Column name reference

Column name in data Placeholder in template
Description {{item.Description}}
Unit Price {{item.Unit_Price}}
Product Name {{item.Product_Name}}
SKU {{item.SKU}}

Spaces and hyphens become underscores. Letters and numbers stay as-is.

Use case examples

Invoice with line items

Main data: invoice number, client name, invoice date, due date, total, bank details
Line items: description, quantity, unit price, amount, VAT rate

The table expands to fit however many services or products were sold: one row for a single consultation, ten rows for a complex project. The totals row below the table stays in place either way.


Packing list / delivery note

Main data: order number, ship-to address, carrier, tracking number
Line items: product name, SKU, quantity ordered, quantity shipped, weight

Ten items on the order, ten rows in the document. Each shipment gets its own correctly populated packing list without any manual work.


Student school report

Main data: student name, student ID, year level, class teacher, term, school name
Line items: subject, teacher, grade, percentage, comment

Generate the entire cohort’s reports in one batch run. A student taking 6 subjects gets 6 rows; one taking 10 gets 10. Same template, same run.


Payslip

Main data: employee name, employee ID, pay period, pay date, bank account
Line items: earnings/deduction type, description, hours (if applicable), amount

Payslips differ per employee: some have overtime, others have allowances or deductions. The line items table handles every variation without needing a separate template for each case.


Event agenda / conference programme

Main data: event name, date, venue, host name
Line items: time slot, session title, presenter, room

Produce individual attendee booklets or a master run-of-show from the same data source. Add or remove sessions in your spreadsheet; the agenda updates automatically on the next run.


Main data: client name, matter reference, partner name, date
Line items: task description, estimated hours, rate, subtotal

One client’s letter may have 3 tasks; another’s may have 12. Both come from the same template.


Generating via the API

Pass items alongside data in your API payload:

{
  "template_id": "your-template-id",
  "format": "pdf",
  "data": {
    "InvoiceNo": "INV-001",
    "Client": "Acme Corp",
    "Date": "2026-05-09",
    "Total": "$1,510.00"
  },
  "items": [
    { "Description": "Web Design",          "Qty": "1", "Unit_Price": "$1,500.00", "Amount": "$1,500.00" },
    { "Description": "Domain Registration", "Qty": "1", "Unit_Price": "$10.00",    "Amount": "$10.00"   }
  ]
}
  • items is optional. Omit it and the API works as a standard single-document merge.
  • Keys in items objects must match the column names in your template placeholders (after replacing spaces with underscores).
  • For integrations like Zapier or Make that can’t send nested arrays, items can also be a JSON-encoded string.

Tips

  • Only one line-items table per template is supported. If your template has multiple tables, the first one containing {{item.*}} placeholders is used.
  • The header row never repeats. Only the one data row with {{item.*}} placeholders repeats.
  • Regular placeholders work in the same template. Mix {Client} and {{item.Description}} freely.
  • A document with no matching line items generates with an empty table: the placeholder row is removed, leaving just the header.
  • The join column can have any name. It just needs to appear in both sheets with the same spelling; matching is not case-sensitive.
  • For Airtable: any fields in the linked table (text, numbers, formulas, lookups) are available as {{item.*}} placeholders.

Troubleshooting

The line items table is empty or missing

  • For Excel: check that the join column values in Sheet 2 exactly match Sheet 1 (e.g. INV-001 in both, not INV001 in one and INV-001 in the other).
  • Check that your template data row uses {{item. (double braces), not {item. (single brace).

Spaces in column names aren’t working

  • Replace spaces with underscores in your placeholder. A column called Unit Price becomes {{item.Unit_Price}}.

All documents have the same line items

  • The join column values in Sheet 2 must differ per record. If every Sheet 2 row has the same join value, every document pulls the same items.

I get a “No data found” error

  • For Excel: make sure Sheet 1 (main data) is the first tab and Sheet 2 (line items) is the second tab.

The Airtable linked field doesn’t appear in field mapping

  • Confirm the field type is Link to another record (not a lookup, rollup, or formula).
  • Make sure your Airtable integration has access to both the parent table and the linked table.
Scroll to Top