-
Notifications
You must be signed in to change notification settings - Fork 107
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 |
--browser |
bool | No | false |
Open HTML output in default browser (html mode only) |
| 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 |
html |
h |
HTML preview (PowerPoint only) — outputs to stdout by default, or opens in browser with --browser
|
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, output is wrapped in a standard envelope. stats, outline, and text modes return structured data instead of plain text:
-
text --json: Array of slides/sheets/paragraphs with text arrays -
outline --json: Array of structural objects (slide titles, shape counts, etc.) -
stats --json: Object with numeric fields (counts, distributions) -
annotated --json: Plain text inContentfield (legacy format)
{
"success": true,
"data": { ... }
}For annotated mode, data is a ViewResult object: { "View": "annotated", "Content": "..." }.
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 wrapped in the standard envelope:
{
"success": true,
"data": {
"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.28