-
Notifications
You must be signed in to change notification settings - Fork 108
command add
zmworm edited this page Apr 2, 2026
·
24 revisions
Add a new element to the document.
officecli add <file> <parent> --type <type> [--index N] [--prop key=value ...]
officecli add <file> <parent> --from <source-path> [--index N]
Adds a new element to the document at the specified parent path. You can either create a new element with --type and --prop, or copy an existing element with --from. Returns the path to the newly created element.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
file |
FileInfo | Yes | - | Office document path |
parent |
string | Yes | - | Parent DOM path where the element will be inserted |
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
--type |
string | Yes (unless --from) |
- | Element type to create |
--from |
string | No | - | Path to an existing element to copy (alternative to --type) |
--index |
int | No | append to end | Insert position (0-based) |
--prop |
string (repeatable) | No | - | Property in key=value format |
Either --type or --from must be specified.
-
Word add - All addable elements in
.docx -
Excel add - All addable elements in
.xlsx -
PowerPoint add - All addable elements in
.pptx
officecli add slides.pptx / --from /slide[1]
officecli add slides.pptx /slide[2] --from /slide[1]/shape[1]
officecli add report.docx /body --from /body/p[1] --index 5- Command Reference
- set - Modify existing elements
- remove - Remove elements
Based on OfficeCLI v1.0.29