Skip to content

command raw

zmworm edited this page Mar 31, 2026 · 23 revisions

raw / raw-set / add-part

Low-level XML operations for viewing and modifying document internals.

raw - View Raw XML

officecli raw <file> [part] [--start N] [--end N] [--cols A,B,C]
Name Type Required Default Description
file FileInfo Yes - Office document path
part string No /document Part path
--start int No - Start row (Excel only)
--end int No - End row (Excel only)
--cols string No - Column filter (Excel only)

raw-set - Modify Raw XML

officecli raw-set <file> <part> --xpath <xpath> --action <action> [--xml <fragment>]
Name Type Required Default Description
file FileInfo Yes - Office document path
part string Yes - Part path
--xpath string Yes - XPath to target element(s)
--action string Yes - Action (see below)
--xml string No - XML fragment or name=value for setattr

Actions

Action Description --xml Required
append Add as last child Yes
prepend Add as first child Yes
insertBefore / before Insert before element Yes
insertAfter / after Insert after element Yes
replace Replace element Yes
remove / delete Remove element No
setattr Set attribute (name=value) Yes

add-part - Create New Document Part

officecli add-part <file> <parent> --type <type>

Creates a new part (chart, header, footer) and returns relId + partPath for use with raw-set.

Format-Specific References

  • Word raw - Word parts, namespaces, and examples
  • Excel raw - Excel parts, namespaces, and examples
  • PowerPoint raw - PowerPoint parts, namespaces, and examples

Notes

  • Unprefixed elements in --xml inherit the document's default namespace.
  • Validates before and after modification. New errors reported as warnings.
  • Use raw first to understand the XML structure before using raw-set.

See Also


Based on OfficeCLI v1.0.28

Clone this wiki locally