-
Notifications
You must be signed in to change notification settings - Fork 2k
command merge
goworm edited this page Jul 19, 2026
·
37 revisions
Replace {{key}} template placeholders in Office documents with JSON data.
officecli merge <template> <output> --data <data> [--force] [--json]| Name | Type | Required | Description |
|---|---|---|---|
template |
FileInfo | Yes | Source template document (.docx, .xlsx, .pptx) |
output |
FileInfo | Yes | Output file path |
| Name | Type | Required | Description |
|---|---|---|---|
--data |
string | Yes | Inline JSON object or path to a .json file. Not positional — data must follow --data; a bare third argument is rejected as unrecognized. |
--force |
bool | No | Overwrite an existing output file |
--json |
bool | No | Output as structured JSON |
- Copies the template to the output path, then replaces all
{{key}}placeholders with values from the JSON data. - Works across all text content: paragraphs, runs, table cells, shapes, headers, footers, chart titles, etc.
- Returns the count of replacements and lists any unresolved
{{...}}placeholders still remaining.
# Inline JSON data
officecli merge template.docx output.docx --data '{"name":"Alice","dept":"Sales","date":"2026-03-26"}'
# JSON file
officecli merge template.pptx report.pptx --data data.json
# Excel template
officecli merge budget-template.xlsx q4-budget.xlsx --data '{"quarter":"Q4","year":"2026"}'Place {{key}} markers anywhere in the document text:
Dear {{name}},
Your department ({{dept}}) budget for {{quarter}} {{year}} has been approved.
Keys are case-sensitive and must match the JSON property names exactly.
Nested JSON objects are addressable via dot-path placeholders:
{"customer":{"name":"Alice","address":{"city":"Berlin"}},"order":{"total":"1200"}}Dear {{customer.name}}, ship to {{customer.address.city}}. Total: {{order.total}}.
Arrays must be flattened by the caller into named slots ({{items.0.name}} is not auto-resolved).
- Command Reference - All commands
- batch - Batch multiple operations
Based on OfficeCLI v1.0.139