Skip to content

command add

zmworm edited this page Apr 2, 2026 · 24 revisions

add

Add a new element to the document.

Synopsis

officecli add <file> <parent> --type <type> [--index N] [--prop key=value ...]
officecli add <file> <parent> --from <source-path> [--index N]

Description

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.

Arguments

Name Type Required Default Description
file FileInfo Yes - Office document path
parent string Yes - Parent DOM path where the element will be inserted

Options

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.

Format-Specific References

Copy Mode (--from)

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

See Also


Based on OfficeCLI v1.0.29

Clone this wiki locally