AionUi officecli-xlsx
Use this skill any time a .xlsx file is involved -- as input, output, or both. This includes: creating spreadsheets, financial models, dashboards, or trackers; reading, parsing, or extracting data from any .xlsx file; editing, modifying, or updating existing workbooks; working with formulas, charts, pivot tables, or templates; importing CSV/TSV data into Excel format. Trigger whenever the user mentions 'spreadsheet', 'workbook', 'Excel', 'financial model', 'tracker', 'dashboard', or references a .xlsx/.csv filename.
git clone https://github.com/iOfficeAI/AionUi
T=$(mktemp -d) && git clone --depth=1 https://github.com/iOfficeAI/AionUi "$T" && mkdir -p ~/.claude/skills && cp -r "$T/src/process/resources/skills/officecli-xlsx" ~/.claude/skills/iofficeai-aionui-officecli-xlsx && rm -rf "$T"
src/process/resources/skills/officecli-xlsx/SKILL.mdOfficeCLI XLSX Skill
BEFORE YOU START (CRITICAL)
If
is not installed:officecli
macOS / Linux
if ! command -v officecli >/dev/null 2>&1; then curl -fsSL https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.sh | bash fi
Windows (PowerShell)
if (-not (Get-Command officecli -ErrorAction SilentlyContinue)) { irm https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.ps1 | iex }
Verify:
officecli --version
If
officecli is still not found after first install, open a new terminal and run the verify command again.
Quick Reference
| Task | Action |
|---|---|
| Read / analyze content | Use and commands below |
| Edit existing workbook | Read editing.md |
| Create from scratch | Read creating.md |
Execution Model
Run commands one at a time. Do not write all commands into a shell script and execute it as a single block.
OfficeCLI is incremental: every
add, set, and remove immediately modifies the file and returns output. Use this to catch errors early:
- One command at a time, then read the output. Check the exit code before proceeding.
- Non-zero exit = stop and fix immediately. Do not continue building on a broken state.
- Verify after structural operations. After adding a sheet, chart, pivot table, or named range, run
orget
before building on top of it.validate
Running a 50-command script all at once means the first error cascades silently through every subsequent command. Running incrementally means the failure context is immediate and local — fix it and move on.
Reading & Analyzing
Text Extraction
officecli view data.xlsx text officecli view data.xlsx text --start 1 --end 50 --cols A,B,C
Plain text dump, tab-separated per row, with
[/Sheet1/row[N]] prefixes. Flags: --mode, --start N, --end N, --max-lines N, --cols A,B,C.
Structure Overview
officecli view data.xlsx outline
Sheets with row/column counts and formula counts per sheet.
Detailed Inspection
officecli view data.xlsx annotated
Cell values with type/formula annotations, warnings for errors and empty cells.
Statistics
officecli view data.xlsx stats
Summary statistics across all sheets.
Issue Detection
officecli view data.xlsx issues
Empty sheets, broken formulas, missing references.
Element Inspection
# Workbook root (lists all sheets, doc properties) officecli get data.xlsx / # Sheet overview (freeze, autoFilter, zoom, tabColor) officecli get data.xlsx "/Sheet1" # Single cell (value, type, formula, font, fill, borders, numFmt) officecli get data.xlsx "/Sheet1/A1" # Cell range officecli get data.xlsx "/Sheet1/A1:D10" # Row properties officecli get data.xlsx "/Sheet1/row[1]" # Column properties officecli get data.xlsx "/Sheet1/col[A]" # Chart officecli get data.xlsx "/Sheet1/chart[1]" # Table (ListObject) officecli get data.xlsx "/Sheet1/table[1]" # Data validation rule officecli get data.xlsx "/Sheet1/validation[1]" # Conditional formatting rule officecli get data.xlsx "/Sheet1/cf[1]" # Comment officecli get data.xlsx "/Sheet1/comment[1]" # Named range officecli get data.xlsx "/namedrange[1]"
Add
--depth N to expand children, --json for structured output. Excel-native notation also supported: Sheet1!A1, Sheet1!A1:D10.
CSS-like Queries
# Cells with formulas officecli query data.xlsx 'cell:has(formula)' # Cells containing text officecli query data.xlsx 'cell:contains("Revenue")' # Empty cells officecli query data.xlsx 'cell:empty' # Cells by type officecli query data.xlsx 'cell[type=Number]' # Cells by formatting officecli query data.xlsx 'cell[font.bold=true]' # Column B non-zero officecli query data.xlsx 'B[value!=0]' # Sheet-scoped officecli query data.xlsx 'Sheet1!cell[value="100"]' # Find all charts officecli query data.xlsx 'chart' # Find all tables officecli query data.xlsx 'table' # Find all pivot tables officecli query data.xlsx 'pivottable'
Operators:
=, !=, ~= (contains), >=, <=, [attr] (exists).
Design Principles
Professional spreadsheets need clear structure, correct formulas, and intentional formatting.
Use Formulas, Not Hardcoded Values (MANDATORY)
This is the single most important principle. The spreadsheet must remain dynamic -- when source data changes, formulas recalculate automatically. Hardcoded values break this contract.
# WRONG -- hardcoded calculation result officecli set data.xlsx "/Sheet1/B10" --prop value=5000 # CORRECT -- let Excel calculate officecli set data.xlsx "/Sheet1/B10" --prop formula="SUM(B2:B9)"
Financial Model Color Coding
| Convention | Color | Use For |
|---|---|---|
| Blue text | | Hardcoded inputs, scenario-variable numbers |
| Black text | | ALL formulas and calculations |
| Green text | | Cross-sheet links within same workbook |
| Red text | | External references |
| Yellow background | | Key assumptions needing attention |
These are industry-standard financial modeling conventions. Apply when building financial models. For non-financial workbooks, use project-appropriate styling.
Number Format Strings
| Type | Format String | Example Output | Code |
|---|---|---|---|
| Currency | | $1,234 | |
| Currency (neg parens) | | ($1,234) | |
| Percentage | | 12.5% | |
| Decimal | | 1,234.56 | |
| Accounting | | $ 1,234 | |
| Date | | 2026-03-27 | |
| Date (long) | | March 27, 2026 | |
| Year as text | | 2026 (not 2,026) | |
| Multiples | | 12.5x | |
| Zeros as dash | | - | |
Shell quoting: Number formats containing
$ must use single quotes ('$#,##0') or heredoc in batch mode. Double quotes cause shell variable expansion.
Column Width and Row Height
# Set column width (character units, ~1 char = 7px) officecli set data.xlsx "/Sheet1/col[A]" --prop width=15 officecli set data.xlsx "/Sheet1/col[B]" --prop width=12 # Set row height (points) officecli set data.xlsx "/Sheet1/row[1]" --prop height=20 # Hide column/row officecli set data.xlsx "/Sheet1/col[D]" --prop hidden=true officecli set data.xlsx "/Sheet1/row[5]" --prop hidden=true
There is no auto-fit. Set column widths explicitly. Common widths: labels=20-25, numbers=12-15, dates=12, short codes=8-10.
Freeze Panes
# Freeze first row (headers) officecli set data.xlsx "/Sheet1" --prop freeze=A2 # Freeze first column and first row officecli set data.xlsx "/Sheet1" --prop freeze=B2
Print Area
# Set print area on a sheet officecli set data.xlsx "/Sheet1" --prop printArea="A1:F20"
Data Validation for Input Cells
# Dropdown list officecli add data.xlsx /Sheet1 --type validation --prop sqref="C2:C100" --prop type=list --prop formula1="Yes,No,Maybe" --prop showError=true --prop errorTitle="Invalid" --prop error="Select from list" # Number range officecli add data.xlsx /Sheet1 --type validation --prop sqref="D2:D100" --prop type=decimal --prop operator=between --prop formula1=0 --prop formula2=100 --prop showError=true --prop error="Enter 0-100"
Always add data validation on input cells in financial models and trackers. It prevents data entry errors.
Print Area and Page Setup
For print-ready workbooks, set appropriate column widths and row heights. Consider which sheets need headers repeated on each page.
QA (Required)
Assume there are problems. Your job is to find them.
Your first spreadsheet build is almost never correct. Approach QA as a bug hunt, not a confirmation step. If you found zero issues on first inspection, you were not looking hard enough.
Content QA
# Extract text, check for missing data officecli view data.xlsx text # Check structure officecli view data.xlsx outline # Check for issues (broken formulas, missing refs, empty sheets) officecli view data.xlsx issues # Verify formulas exist where expected officecli query data.xlsx 'cell:has(formula)' # Check for formula errors in cell values officecli query data.xlsx 'cell:contains("#REF!")' officecli query data.xlsx 'cell:contains("#DIV/0!")' officecli query data.xlsx 'cell:contains("#VALUE!")' officecli query data.xlsx 'cell:contains("#NAME?")' officecli query data.xlsx 'cell:contains("#N/A")'
When editing templates, check for leftover placeholders:
officecli query data.xlsx 'cell:contains("{{")' officecli query data.xlsx 'cell:contains("xxxx")' officecli query data.xlsx 'cell:contains("placeholder")'
Formula Verification Checklist
- Test 2-3 sample cell references: verify they pull correct values
- Column mapping: confirm cell references point to intended columns
- Row offsets: check formula ranges include all data rows
- Division by zero: verify denominators are non-zero or wrapped in IFERROR
- Cross-sheet references: use correct
formatSheet1!A1 - Cross-sheet formula escaping: run
on 2-3 cross-sheet formula cells and confirm noofficecli get
in the formula string. If\!
is present, the formula is broken -- delete and re-set using batch/heredoc.\! - Named ranges: verify
values match actual data locationsref - Edge cases: test with zero values, negative numbers, empty cells
- Chart data vs formula results: for every chart with hardcoded/inline data, verify each data point matches the corresponding formula cell result. Use
on the source cells and compare against chart series values. Mismatches here are silent data integrity bugs.officecli get
Validation
officecli validate data.xlsx
Pre-Delivery Checklist
- Metadata set (title, author)
- All formula cells contain formulas (not hardcoded values)
- No formula error values (#REF!, #DIV/0!, #VALUE!, #NAME?, #N/A)
- Number formats applied (currency, percentage, dates)
- Column widths set explicitly (no default 8.43)
- Header row styled (bold, fill, freeze panes)
- Data validation on input cells
- Charts have titles and readable axis labels
- Chart data matches source cells -- charts with hardcoded/inline data can drift from formula results. For each chart, verify every data point against the corresponding cell value. Prefer cell-range references (
) over inline data to avoid transcription errors.series1.values="Sheet1!B2:B6" - Named ranges defined for key assumptions
- Document validates with
officecli validate - No placeholder text remaining
- Comments on hardcoded assumption values documenting their source
NOTE: Unlike pptx (SVG/HTML), xlsx has no visual preview mode. Verification relies on
view text, view annotated, view stats, view issues, validate, and formula queries. For visual verification, the user must open the file in Excel.
Verification Loop
- Generate workbook
- Run
+view issues
(sample ranges) +view annotatedvalidate - Run formula error queries (all 5 error types)
- List issues found (if none found, look again more critically)
- Fix issues
- Re-verify affected areas -- one fix often creates another problem
- Repeat until a full pass reveals no new issues
Do not declare success until you have completed at least one fix-and-verify cycle.
Common Pitfalls
| Pitfall | Correct Approach |
|---|---|
| Use -- all attributes go through |
| Guessing property names | Run to see exact names |
in shell strings | Use for newlines in |
| Modifying an open file | Close the file in Excel first |
Hex colors with | Use not -- no hash prefix |
| Paths are 1-based | , -- XPath convention |
is 0-based | = first position -- array convention |
Unquoted in zsh/bash | Shell glob-expands -- always quote paths: |
| Sheet names with spaces | Quote the full path: |
Formula prefix | OfficeCLI strips the -- use not |
Cross-sheet in formulas | CRITICAL: The in can be corrupted by shell quoting. Use batch/heredoc for cross-sheet formulas, or double quotes: . NEVER use single quotes for formulas containing . After setting, verify with that the formula shows (no backslash before ). |
| Hardcoded calculated values | Use not |
and in batch JSON | Use heredoc: -- single-quoted delimiter prevents shell expansion |
Number format with | Shell interprets -- use single quotes: |
| Year displayed as "2,026" | Set cell type to string: or use |
Performance: Resident Mode
Always use
/open
— it is the smart default, not a special-case optimization. Every command benefits: no repeated file I/O, no repeated parse/serialize cycles.close
officecli open data.xlsx # Load once into memory officecli add data.xlsx ... # All commands run in memory — fast officecli set data.xlsx ... officecli close data.xlsx # Write once to disk
Use this pattern for every workbook build, regardless of command count.
Performance: Batch Mode
cat <<'EOF' | officecli batch data.xlsx [ {"command":"set","path":"/Sheet1/A1","props":{"value":"Revenue","bold":"true","fill":"1F4E79","font.color":"FFFFFF"}}, {"command":"set","path":"/Sheet1/B1","props":{"value":"Q1","bold":"true","fill":"1F4E79","font.color":"FFFFFF"}} ] EOF
Batch supports:
add, set, get, query, remove, move, swap, view, raw, raw-set, validate.
Batch fields:
command, path, parent, type, from, to, index, after, before, props (dict), selector, mode, depth, part, xpath, action, xml.
parent = container to add into (for add). path = element to modify (for set, get, remove, move, swap).
Batch mode executes multiple operations in a single open/save cycle.
Known Issues
| Issue | Workaround |
|---|---|
| Chart series cannot be added after creation | and on an existing chart can only update existing series. To add series, delete and recreate: then with all series. |
| No visual preview | Unlike pptx (SVG/HTML), xlsx has no built-in rendering. Use /// for verification. Users must open in Excel for visual check. |
| Formula cached values for new formulas | OfficeCLI writes formula strings natively. For newly added formulas, the cached value may not update until the file is opened in Excel/LibreOffice. Existing formula cached values are preserved. |
| No auto-fit column width | No "auto-fit" column width based on content. Set explicitly on each column. |
| Shell quoting in batch with echo | fails when JSON values contain apostrophes or . Use heredoc: . |
| Batch intermittent failure | Batch+resident mode has a high failure rate (up to 1-in-3 in some sessions). For maximum reliability: (1) prefer batch WITHOUT resident mode, (2) keep batches to 8-12 operations, (3) always check batch output for failures, (4) retry failed operations individually. For critical formulas (especially cross-sheet), consider using individual commands which have 100% reliability. |
| Data bar default min/max invalid | Creating a data bar without produces empty attributes in cfvo elements, which may be rejected by strict XML validators or Excel. Always specify explicit min and max values. |
| Cell protection requires sheet protection | and properties only take effect when the sheet itself is protected. |
Help System
When unsure about property names, value formats, or command syntax, run help instead of guessing. One help query is faster than guess-fail-retry loops.
officecli xlsx set # All settable elements and their properties officecli xlsx set cell # Cell properties in detail officecli xlsx set cell.font # Specific property format and examples officecli xlsx add # All addable element types officecli xlsx view # All view modes officecli xlsx get # All navigable paths officecli xlsx query # Query selector syntax