-
Notifications
You must be signed in to change notification settings - Fork 107
command open
Start and stop a resident background process for faster multi-command workflows.
officecli open <file>
officecli close <file>
Starts a background resident process that keeps the document loaded in memory. All subsequent commands targeting this file communicate with the resident via named pipes, avoiding repeated file I/O. This dramatically improves performance for multi-step workflows.
If a resident process is already running for the file, the command returns immediately without starting a duplicate.
Stops the resident process for the specified file, saving any pending changes. After closing, commands revert to direct file access mode.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
file |
FileInfo | Yes | - | Office document path (.docx, .xlsx, .pptx) |
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
--json |
bool | No | false |
Output result as JSON envelope |
Each resident process creates two named pipes:
- Main pipe: Handles command execution (serialized with a semaphore lock)
- Ping pipe: Always responsive for connection checks and shutdown signals
The resident process automatically shuts down after 12 minutes of inactivity. The timer resets on every command.
Commands are executed sequentially. Only one command runs at a time, ensuring data integrity.
All commands (view, get, set, add, etc.) automatically detect whether a resident is running. If a resident is available, the command routes through it. Otherwise, the command falls back to direct file access. This means you can use the same command syntax regardless of mode.
# Start resident process
officecli open report.docx
# Run multiple commands (automatically uses resident)
officecli view report.docx text
officecli set report.docx /body/p[1] --prop bold=true
officecli add report.docx /body --type paragraph --prop text="New paragraph"
officecli set report.docx /body/p[2] --prop style=Heading1
# Save and close
officecli close report.docx# Multi-step Excel workflow
officecli open data.xlsx
officecli set data.xlsx /Sheet1/A1 --prop value="Header" --prop bold=true
officecli set data.xlsx /Sheet1/A2 --prop value=100
officecli set data.xlsx /Sheet1/A3 --prop formula="=SUM(A2:A2)"
officecli close data.xlsx- The
opencommand waits up to 5 seconds for the resident to become responsive. - You cannot use
createon a file that has an active resident process. - If the resident crashes or is killed, subsequent commands automatically fall back to direct mode.
- Command Reference
- batch - Alternative for multi-command workflows
Based on OfficeCLI v1.0.28