-
Notifications
You must be signed in to change notification settings - Fork 116
command swap
zmworm edited this page Apr 4, 2026
·
27 revisions
Swap two elements' positions.
officecli swap <file> <path1> <path2>
Swaps the positions of two elements. Both elements must have the same parent (e.g., two paragraphs in the same body, two rows in the same table, two slides in the same presentation).
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
file |
FileInfo | Yes | - | Office document path |
path1 |
string | Yes | - | DOM path of the first element |
path2 |
string | Yes | - | DOM path of the second element |
# Swap two paragraphs
officecli swap report.docx /body/p[1] /body/p[3]
# Swap two table rows
officecli swap report.docx /body/tbl[1]/tr[1] /body/tbl[1]/tr[3]# Swap two rows on the same sheet
officecli swap data.xlsx /Sheet1/row[1] /Sheet1/row[3]# Swap two slides
officecli swap slides.pptx /slide[1] /slide[3]
# Swap two shapes on the same slide
officecli swap slides.pptx /slide[1]/shape[1] /slide[1]/shape[2]- Both elements must share the same parent container.
- After swapping, the indices of the elements change accordingly.
- move - Move elements to a new position or parent
- Command Reference
Based on OfficeCLI v1.0.33