-
Notifications
You must be signed in to change notification settings - Fork 541
command view
View document content in various display modes.
officecli view <file> <mode> [options]
Displays document content in one of five modes. Read-only.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
file |
FileInfo | Yes | - | Office document path |
mode |
string | Yes | - | View mode (see below) |
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
--start |
int | No | - | Start line/paragraph/slide number |
--end |
int | No | - | End line/paragraph/slide number |
--max-lines |
int | No | - | Maximum output lines (truncates with total count) |
--type |
string | No | - | Issue type filter (issues mode only): format, content, structure
|
--limit |
int | No | - | Maximum number of results |
--cols |
string | No | - | Column filter, comma-separated (Excel only, e.g., A,B,C) |
--json |
bool | No | false |
Output as structured JSON |
| Mode | Short | Description |
|---|---|---|
text |
t |
Plain text content with element paths |
annotated |
a |
Text with formatting details (font, size, bold, style) |
outline |
o |
Hierarchical document structure |
stats |
s |
Statistics (style distribution, font usage, etc.) |
issues |
i |
Detected formatting/content/structure problems |
The output format depends on the view mode and whether --json is used.
These modes output the raw content as a plain text string. The exact layout depends on the mode (e.g., text shows plain content, annotated includes formatting annotations, outline shows indented structure, stats shows tabulated statistics).
With --json, the content is wrapped in a JSON object:
{
"View": "text",
"Content": "Line 1\nLine 2\nLine 3..."
}The View field indicates the mode used, and Content contains the full rendered text as a single string.
The issues mode detects formatting, content, and structure problems in the document. The output format differs between text and JSON.
Issues are grouped by type (Structure, Format, Content), with each issue showing its ID, path, message, context, and suggestion.
Found {N} issue(s):
{Type} Issues ({count}):
[{Id}] {Path}: {Message}
Context: "{context}"
Suggestion: {suggestion}
Example:
Found 3 issue(s):
Structure Issues (1):
[S1] /body/p[5]: Empty paragraph detected
Context: ""
Suggestion: Remove empty paragraph or add content
Format Issues (2):
[F1] /body/p[2]/r[1]: Inconsistent font size
Context: "This text uses 13pt"
Suggestion: Use standard font size (11pt or 12pt)
[F2] /body/p[7]/r[1]: Direct formatting overrides style
Context: "Bold applied directly"
Suggestion: Use a character style instead of direct bold
With --json, issues are returned as a structured object with a count and an array of issue details.
{
"Count": 3,
"Issues": [
{
"Id": "S1",
"Type": "Structure",
"Severity": "Warning",
"Path": "/body/p[5]",
"Message": "Empty paragraph detected",
"Context": "",
"Suggestion": "Remove empty paragraph or add content"
},
{
"Id": "F1",
"Type": "Format",
"Severity": "Warning",
"Path": "/body/p[2]/r[1]",
"Message": "Inconsistent font size",
"Context": "This text uses 13pt",
"Suggestion": "Use standard font size (11pt or 12pt)"
}
]
}| Field | Type | Description |
|---|---|---|
Id |
string | Issue identifier (e.g., S1, F1, C1) prefixed by type |
Type |
string | Issue category: Structure, Format, or Content
|
Severity |
string | Issue severity level (e.g., Warning) |
Path |
string | DOM path to the element with the issue |
Message |
string | Description of the problem |
Context |
string | Relevant text or content near the issue |
Suggestion |
string | Recommended fix for the issue |
- Word view - Word view modes and output details
- Excel view - Excel view modes and output details
- PowerPoint view - PowerPoint view modes and output details
- Command Reference
- get - Get specific elements by path
- query - Find elements by selector
Based on OfficeCli v1.0.6