Skip to content

workflows

zmworm edited this page Mar 31, 2026 · 23 revisions

End-to-End Workflow Examples

Real-world workflows showing complete sequences of OfficeCLI commands. Each workflow builds a document from scratch or performs a multi-step operation.

1. Create a Word Report from Scratch

Build a professional report with headings, body text, a data table, an image, watermark, and header/footer.

# Create a blank Word document
officecli create report.docx

# Start resident mode for fast multi-command workflow
officecli open report.docx

# Set document metadata
officecli set report.docx / --prop title="Q4 2025 Sales Report" --prop author="Finance Team"

# Add the report title
officecli add report.docx /body --type paragraph --prop text="Q4 2025 Sales Report" --prop style=Heading1

# Add an executive summary heading and body text
officecli add report.docx /body --type paragraph --prop text="Executive Summary" --prop style=Heading2
officecli add report.docx /body --type paragraph \
  --prop text="This report presents the sales performance for Q4 2025. Revenue exceeded targets by 12%, driven by strong demand in the enterprise segment." \
  --prop font=Arial --prop size=11

# Add a findings section
officecli add report.docx /body --type paragraph --prop text="Key Findings" --prop style=Heading2
officecli add report.docx /body --type paragraph \
  --prop text="Revenue grew 15% quarter-over-quarter." --prop listStyle=bullet
officecli add report.docx /body --type paragraph \
  --prop text="Enterprise accounts contributed 65% of total revenue." --prop listStyle=bullet
officecli add report.docx /body --type paragraph \
  --prop text="Customer retention rate remained above 95%." --prop listStyle=bullet

# Add a data table (4 rows x 3 columns)
officecli add report.docx /body --type table --prop rows=4 --prop cols=3

# Style the header row
officecli set report.docx /body/tbl[1]/tr[1]/tc[1] \
  --prop text="Region" --prop bold=true --prop shd=4472C4 --prop color=FFFFFF --prop alignment=center
officecli set report.docx /body/tbl[1]/tr[1]/tc[2] \
  --prop text="Revenue" --prop bold=true --prop shd=4472C4 --prop color=FFFFFF --prop alignment=center
officecli set report.docx /body/tbl[1]/tr[1]/tc[3] \
  --prop text="Growth" --prop bold=true --prop shd=4472C4 --prop color=FFFFFF --prop alignment=center

# Fill in data rows
officecli set report.docx /body/tbl[1]/tr[2]/tc[1] --prop text="North America"
officecli set report.docx /body/tbl[1]/tr[2]/tc[2] --prop text="$4.2M"
officecli set report.docx /body/tbl[1]/tr[2]/tc[3] --prop text="+18%"
officecli set report.docx /body/tbl[1]/tr[3]/tc[1] --prop text="Europe"
officecli set report.docx /body/tbl[1]/tr[3]/tc[2] --prop text="$2.8M"
officecli set report.docx /body/tbl[1]/tr[3]/tc[3] --prop text="+12%"
officecli set report.docx /body/tbl[1]/tr[4]/tc[1] --prop text="Asia Pacific"
officecli set report.docx /body/tbl[1]/tr[4]/tc[2] --prop text="$1.5M"
officecli set report.docx /body/tbl[1]/tr[4]/tc[3] --prop text="+22%"

# Center the table
officecli set report.docx /body/tbl[1] --prop alignment=center --prop width=100%

# Add an image (e.g., a chart screenshot)
officecli add report.docx /body --type picture \
  --prop path=sales-chart.png --prop width=5in --prop height=3in --prop alt="Q4 Sales Chart"

# Add a CONFIDENTIAL watermark
officecli add report.docx / --type watermark --prop text=CONFIDENTIAL --prop color=FF0000 --prop opacity=0.2

# Add a header and footer
officecli add report.docx / --type header --prop text="Acme Corp - Confidential" --prop alignment=center --prop size=9
officecli add report.docx / --type footer --prop text="Q4 2025 Sales Report" --prop alignment=right --prop size=9

# Validate the document
officecli validate report.docx

# Save and close
officecli close report.docx

See also: create, open / close, Word add, Word set, Word Paragraph, Word Table, Word Picture, Word Watermark, Word Header/Footer, validate


2. Create an Excel Spreadsheet with Data

Build a sales tracking spreadsheet with formatted headers, formulas, number formats, merged title, frozen panes, data validation, a chart, and a named range.

# Create a blank Excel workbook
officecli create sales.xlsx

# Start resident mode
officecli open sales.xlsx

# Set up column headers with formatting
officecli set sales.xlsx /Sheet1/A1 --prop value="Product" --prop bold=true --prop fill=4472C4 --prop color=FFFFFF --prop halign=center
officecli set sales.xlsx /Sheet1/B1 --prop value="Units Sold" --prop bold=true --prop fill=4472C4 --prop color=FFFFFF --prop halign=center
officecli set sales.xlsx /Sheet1/C1 --prop value="Unit Price" --prop bold=true --prop fill=4472C4 --prop color=FFFFFF --prop halign=center
officecli set sales.xlsx /Sheet1/D1 --prop value="Revenue" --prop bold=true --prop fill=4472C4 --prop color=FFFFFF --prop halign=center
officecli set sales.xlsx /Sheet1/E1 --prop value="Status" --prop bold=true --prop fill=4472C4 --prop color=FFFFFF --prop halign=center

# Enter data values
officecli set sales.xlsx /Sheet1/A2 --prop value="Widget A"
officecli set sales.xlsx /Sheet1/B2 --prop value=150
officecli set sales.xlsx /Sheet1/C2 --prop value=29.99
officecli set sales.xlsx /Sheet1/A3 --prop value="Widget B"
officecli set sales.xlsx /Sheet1/B3 --prop value=230
officecli set sales.xlsx /Sheet1/C3 --prop value=49.99
officecli set sales.xlsx /Sheet1/A4 --prop value="Widget C"
officecli set sales.xlsx /Sheet1/B4 --prop value=85
officecli set sales.xlsx /Sheet1/C4 --prop value=99.99
officecli set sales.xlsx /Sheet1/A5 --prop value="Widget D"
officecli set sales.xlsx /Sheet1/B5 --prop value=310
officecli set sales.xlsx /Sheet1/C5 --prop value=19.99

# Add revenue formulas (Units Sold * Unit Price)
officecli set sales.xlsx /Sheet1/D2 --prop formula="=B2*C2"
officecli set sales.xlsx /Sheet1/D3 --prop formula="=B3*C3"
officecli set sales.xlsx /Sheet1/D4 --prop formula="=B4*C4"
officecli set sales.xlsx /Sheet1/D5 --prop formula="=B5*C5"

# Add a totals row
officecli set sales.xlsx /Sheet1/A6 --prop value="TOTAL" --prop bold=true
officecli set sales.xlsx /Sheet1/B6 --prop formula="=SUM(B2:B5)" --prop bold=true
officecli set sales.xlsx /Sheet1/D6 --prop formula="=SUM(D2:D5)" --prop bold=true

# Set number formats for currency and quantity columns
officecli set sales.xlsx /Sheet1/C2:C5 --prop numFmt="#,##0.00"
officecli set sales.xlsx /Sheet1/D2:D6 --prop numFmt="#,##0.00"
officecli set sales.xlsx /Sheet1/B2:B6 --prop numFmt="#,##0"

# Add a merged title row above the data (insert at row 1 would shift data, so use a separate range)
# Merge cells A1:E1 is already the header row; instead add a title on a summary sheet or use row above
# For this example, we merge a range for a visual section header on row 7
officecli set sales.xlsx /Sheet1/A7:E7 --prop merge=true
officecli set sales.xlsx /Sheet1/A7 --prop value="Sales Summary - Q4 2025" --prop bold=true --prop size=14 --prop halign=center

# Freeze panes so the header row stays visible when scrolling
officecli set sales.xlsx /Sheet1 --prop freeze=A2

# Add a dropdown validation for the Status column
officecli add sales.xlsx /Sheet1 --type validation \
  --prop sqref=E2:E100 \
  --prop type=list \
  --prop formula1="Active,Discontinued,Pending" \
  --prop promptTitle="Status" \
  --prop prompt="Select product status"

# Add a column chart visualizing revenue
officecli add sales.xlsx /Sheet1 --type chart \
  --prop chartType=column \
  --prop title="Revenue by Product" \
  --prop data=A1:D5 \
  --prop x=0 --prop y=10 \
  --prop width=800 --prop height=400 \
  --prop yAxisTitle="Revenue ($)"

# Add a named range for the data area
officecli add sales.xlsx / --type namedrange \
  --prop name="SalesData" --prop ref="Sheet1!A1:E5" --prop comment="Q4 product sales data"

# Validate the workbook
officecli validate sales.xlsx

# Save and close
officecli close sales.xlsx

See also: create, open / close, Excel add, Excel set, Excel Cell, Excel Sheet, Excel Validation, Excel Chart, Excel Named Range, validate


3. Create a PowerPoint Presentation

Build a presentation with a title slide, styled backgrounds, content slides with shapes, a chart, a table, an image, animations, transitions, and speaker notes.

# Create a blank PowerPoint file
officecli create deck.pptx

# Start resident mode
officecli open deck.pptx

# Set slide size to widescreen 16:9
officecli set deck.pptx / --prop slideSize=16:9

# Add a title slide with dark background
officecli add deck.pptx / --type slide --prop layout=title
officecli set deck.pptx /slide[1] --prop background=1A1A2E

# Add title text as a shape
officecli add deck.pptx /slide[1] --type shape \
  --prop text="Q4 2025 Business Review" \
  --prop x=3cm --prop y=5cm --prop width=20cm --prop height=4cm \
  --prop font=Arial --prop size=36 --prop bold=true --prop color=FFFFFF --prop fill=none
officecli add deck.pptx /slide[1] --type shape \
  --prop text="Presented by the Strategy Team" \
  --prop x=3cm --prop y=10cm --prop width=20cm --prop height=2cm \
  --prop font=Arial --prop size=18 --prop color=CCCCCC --prop fill=none

# Add a content slide with a bar chart
officecli add deck.pptx / --type slide --prop layout=blank
officecli set deck.pptx /slide[2] --prop "background=4472C4-1A1A2E-270"
officecli add deck.pptx /slide[2] --type shape \
  --prop text="Revenue by Quarter" \
  --prop x=1cm --prop y=0.5cm --prop width=22cm --prop height=2cm \
  --prop font=Arial --prop size=28 --prop bold=true --prop color=FFFFFF --prop fill=none
officecli add deck.pptx /slide[2] --type chart \
  --prop chartType=bar \
  --prop title="Revenue ($M)" \
  --prop categories="Q1,Q2,Q3,Q4" \
  --prop series1="2025:2.1,2.8,3.2,4.5" \
  --prop series2="2024:1.8,2.3,2.7,3.6" \
  --prop x=2cm --prop y=3cm --prop width=20cm --prop height=13cm \
  --prop legend=bottom --prop colors=4472C4,ED7D31

# Add a slide with a data table
officecli add deck.pptx / --type slide --prop layout=blank
officecli set deck.pptx /slide[3] --prop background=FFFFFF
officecli add deck.pptx /slide[3] --type shape \
  --prop text="Regional Performance" \
  --prop x=1cm --prop y=0.5cm --prop width=22cm --prop height=2cm \
  --prop font=Arial --prop size=28 --prop bold=true --prop color=1A1A2E --prop fill=none

# Create a 4x4 table
officecli add deck.pptx /slide[3] --type table \
  --prop rows=4 --prop cols=4 \
  --prop x=2cm --prop y=3cm --prop width=20cm --prop height=8cm

# Style the table header row
officecli set deck.pptx /slide[3]/table[1]/tr[1]/tc[1] --prop text="Region" --prop bold=true --prop fill=4472C4 --prop color=FFFFFF --prop align=center
officecli set deck.pptx /slide[3]/table[1]/tr[1]/tc[2] --prop text="Revenue" --prop bold=true --prop fill=4472C4 --prop color=FFFFFF --prop align=center
officecli set deck.pptx /slide[3]/table[1]/tr[1]/tc[3] --prop text="Target" --prop bold=true --prop fill=4472C4 --prop color=FFFFFF --prop align=center
officecli set deck.pptx /slide[3]/table[1]/tr[1]/tc[4] --prop text="Variance" --prop bold=true --prop fill=4472C4 --prop color=FFFFFF --prop align=center

# Fill in data rows
officecli set deck.pptx /slide[3]/table[1]/tr[2]/tc[1] --prop text="North America"
officecli set deck.pptx /slide[3]/table[1]/tr[2]/tc[2] --prop text="$4.2M"
officecli set deck.pptx /slide[3]/table[1]/tr[2]/tc[3] --prop text="$3.8M"
officecli set deck.pptx /slide[3]/table[1]/tr[2]/tc[4] --prop text="+10.5%" --prop color=00AA00
officecli set deck.pptx /slide[3]/table[1]/tr[3]/tc[1] --prop text="Europe"
officecli set deck.pptx /slide[3]/table[1]/tr[3]/tc[2] --prop text="$2.8M"
officecli set deck.pptx /slide[3]/table[1]/tr[3]/tc[3] --prop text="$3.0M"
officecli set deck.pptx /slide[3]/table[1]/tr[3]/tc[4] --prop text="-6.7%" --prop color=FF0000
officecli set deck.pptx /slide[3]/table[1]/tr[4]/tc[1] --prop text="Asia Pacific"
officecli set deck.pptx /slide[3]/table[1]/tr[4]/tc[2] --prop text="$1.5M"
officecli set deck.pptx /slide[3]/table[1]/tr[4]/tc[3] --prop text="$1.2M"
officecli set deck.pptx /slide[3]/table[1]/tr[4]/tc[4] --prop text="+25.0%" --prop color=00AA00

# Set table style
officecli set deck.pptx /slide[3]/table[1] --prop style=medium2

# Add a slide with a picture
officecli add deck.pptx / --type slide --prop layout=blank
officecli set deck.pptx /slide[4] --prop background=F5F5F5
officecli add deck.pptx /slide[4] --type shape \
  --prop text="Our Team" \
  --prop x=1cm --prop y=0.5cm --prop width=22cm --prop height=2cm \
  --prop font=Arial --prop size=28 --prop bold=true --prop color=1A1A2E --prop fill=none
officecli add deck.pptx /slide[4] --type picture \
  --prop path=team-photo.jpg --prop x=4cm --prop y=3.5cm --prop width=16cm --prop height=10cm \
  --prop alt="Team photo from the annual offsite"

# Add animations to shapes on slide 1
officecli set deck.pptx /slide[1]/shape[1] --prop animation=fade-entrance-800
officecli set deck.pptx /slide[1]/shape[2] --prop animation=fade-entrance-500-after

# Add transitions between slides
officecli set deck.pptx /slide[1] --prop transition=fade
officecli set deck.pptx /slide[2] --prop transition=wipe-left
officecli set deck.pptx /slide[3] --prop transition=push-left
officecli set deck.pptx /slide[4] --prop transition=dissolve

# Add speaker notes
officecli add deck.pptx /slide[1] --type notes --prop text="Welcome everyone. Today we will review Q4 2025 performance."
officecli add deck.pptx /slide[2] --type notes --prop text="Highlight the 25% YoY growth in Q4. Call out enterprise segment."
officecli add deck.pptx /slide[3] --type notes --prop text="Europe missed target due to currency headwinds. APAC outperformed."
officecli add deck.pptx /slide[4] --type notes --prop text="Recognize the team for their outstanding work this quarter."

# Validate the presentation
officecli validate deck.pptx

# Save and close
officecli close deck.pptx

See also: create, open / close, PPT add, PPT set, PPT Presentation, PPT Slide, PPT Shape, PPT Chart, PPT Table, PPT Picture, PPT Notes, validate


4. Batch Modify an Existing Document

Use the batch command to apply multiple changes in a single open/save cycle. This is ideal when you need atomic updates and do not need to inspect intermediate results.

# Apply several formatting changes to an existing report in one shot
echo '[
  {"command": "set", "path": "/", "props": {"title": "Updated Report", "author": "Ops Team"}},
  {"command": "set", "path": "/body/p[1]", "props": {"style": "Heading1", "text": "Revised Executive Summary"}},
  {"command": "add", "parent": "/body", "type": "paragraph", "props": {"text": "This section has been updated with latest figures.", "font": "Arial", "size": "11"}},
  {"command": "set", "path": "/body/tbl[1]/tr[1]/tc[1]", "props": {"bold": "true", "shd": "2E75B6", "color": "FFFFFF"}},
  {"command": "set", "path": "/body/tbl[1]/tr[1]/tc[2]", "props": {"bold": "true", "shd": "2E75B6", "color": "FFFFFF"}},
  {"command": "set", "path": "/body/tbl[1]/tr[1]/tc[3]", "props": {"bold": "true", "shd": "2E75B6", "color": "FFFFFF"}},
  {"command": "set", "path": "/body/tbl[1]/tr[2]/tc[2]", "props": {"text": "$5.1M"}},
  {"command": "set", "path": "/body/tbl[1]/tr[3]/tc[2]", "props": {"text": "$3.3M"}},
  {"command": "validate"}
]' | officecli batch report.docx
# Batch update an Excel spreadsheet: add a sheet, populate it, and add a chart
echo '[
  {"command": "add", "parent": "/", "type": "sheet", "props": {"name": "Summary"}},
  {"command": "set", "path": "/Summary/A1", "props": {"value": "Category", "bold": "true", "fill": "4472C4", "color": "FFFFFF"}},
  {"command": "set", "path": "/Summary/B1", "props": {"value": "Total", "bold": "true", "fill": "4472C4", "color": "FFFFFF"}},
  {"command": "set", "path": "/Summary/A2", "props": {"value": "Hardware"}},
  {"command": "set", "path": "/Summary/B2", "props": {"value": "45000", "numFmt": "#,##0"}},
  {"command": "set", "path": "/Summary/A3", "props": {"value": "Software"}},
  {"command": "set", "path": "/Summary/B3", "props": {"value": "72000", "numFmt": "#,##0"}},
  {"command": "set", "path": "/Summary/A4", "props": {"value": "Services"}},
  {"command": "set", "path": "/Summary/B4", "props": {"value": "31000", "numFmt": "#,##0"}},
  {"command": "add", "parent": "/Summary", "type": "chart", "props": {"chartType": "pie", "title": "Revenue Breakdown", "data": "A1:B4", "legend": "bottom"}}
]' | officecli batch data.xlsx
# Batch update a PowerPoint presentation
echo '[
  {"command": "add", "parent": "/", "type": "slide", "props": {"layout": "blank"}},
  {"command": "add", "parent": "/slide[1]", "type": "shape", "props": {"text": "Thank You!", "x": "5cm", "y": "6cm", "width": "15cm", "height": "5cm", "font": "Arial", "size": "44", "bold": "true", "color": "4472C4", "fill": "none"}},
  {"command": "set", "path": "/slide[1]", "props": {"transition": "fade", "background": "FFFFFF"}}
]' | officecli batch deck.pptx

See also: batch, Command Reference


5. Inspect and Fix Document Issues

Use read-only commands to diagnose problems in a document, then fix them.

# View the document outline to understand its structure
officecli view report.docx outline

# Check for formatting, content, and structure issues
officecli view report.docx issues

# Filter to only structural issues
officecli view report.docx issues --type structure

# Query for specific problems: find paragraphs with no style applied
officecli query report.docx "paragraph[style=Normal]"

# Query for images missing alt text
officecli query report.docx "image:no-alt"

# Fix a detected issue: apply a proper heading style to paragraph 3
officecli set report.docx /body/p[3] --prop style=Heading2

# Fix inconsistent font: set all runs in a paragraph to the same font
officecli set report.docx /body/p[5] --prop font=Arial --prop size=11

# Validate the document after fixes
officecli validate report.docx
# Excel: inspect and fix
officecli view data.xlsx outline
officecli view data.xlsx issues

# Find cells with formulas
officecli query data.xlsx "cell[formula=true]"

# Find empty cells in column B
officecli query data.xlsx "B[empty=true]"

# Fix a broken formula
officecli set data.xlsx /Sheet1/D10 --prop formula="=SUM(D2:D9)"

officecli validate data.xlsx
# PowerPoint: inspect and fix
officecli view deck.pptx outline
officecli view deck.pptx issues

# Validate after fixing
officecli validate deck.pptx

See also: view, query - Word, query - Excel, query - PPT, set, validate


6. Use Resident Mode for Multi-Step Workflows

Resident mode keeps the document loaded in memory. All commands route through the resident process via named pipes, avoiding repeated file I/O. This is significantly faster for workflows with many sequential commands.

# Start resident mode -- the document is loaded once into memory
officecli open report.docx

# Read operations go through the resident (no file re-read)
officecli view report.docx outline
officecli get report.docx /body/p[1]
officecli query report.docx "paragraph[style=Heading1]"

# Write operations modify the in-memory document (no file write yet)
officecli set report.docx /body/p[1] --prop text="Updated Title" --prop bold=true
officecli add report.docx /body --type paragraph --prop text="New section content" --prop style=Normal
officecli set report.docx /body/tbl[1]/tr[2]/tc[1] --prop text="Revised value"

# More reads to verify changes (still in memory, instant)
officecli get report.docx /body/p[1]
officecli view report.docx text --start 1 --end 5

# Save and close -- the document is written to disk once
officecli close report.docx

Why resident mode is faster

Mode File Opens File Saves Best For
Direct (default) 1 per command 1 per write command Single commands or scripts with few steps
Resident (open/close) 1 total 1 total Interactive workflows, many sequential commands
Batch 1 total 1 total Applying a known set of changes atomically

In a workflow with 20 commands, direct mode opens and saves the file up to 20 times. Resident mode opens once and saves once at close, with each intermediate command communicating through named pipes at near-zero latency.

Resident mode also provides automatic fallback: if the resident process is not running, commands silently fall back to direct file access. You can use the same command syntax regardless of whether open was called.

See also: open / close, batch, Command Reference


Based on OfficeCLI v1.0.28

Clone this wiki locally