Skip to content

command view

zmworm edited this page Mar 31, 2026 · 23 revisions

view

View document content in various display modes.

Synopsis

officecli view <file> <mode> [options]

Description

Displays document content in one of five modes. Read-only.

Arguments

Name Type Required Default Description
file FileInfo Yes - Office document path
mode string Yes - View mode (see below)

Options

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)

View Modes

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

Output Format

The output format depends on the view mode and whether --json is used.

Text/Annotated/Outline/Stats Modes

Text Output (default)

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).

JSON Output (--json)

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 in Content field (legacy format)
{
  "success": true,
  "data": { ... }
}

For annotated mode, data is a ViewResult object: { "View": "annotated", "Content": "..." }.

Issues Mode

The issues mode detects formatting, content, and structure problems in the document. The output format differs between text and JSON.

Issues Text Output (default)

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

Issues JSON Output (--json)

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)"
    }
    ]
  }
}

Issue Fields

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

Format-Specific References

See Also


Based on OfficeCLI v1.0.28

Clone this wiki locally