$npx -y skills add iOfficeAI/OfficeCLI --skill officecli-xlsxUse 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 wi
| 1 | # OfficeCLI XLSX Skill |
| 2 | |
| 3 | ## Setup |
| 4 | |
| 5 | If `officecli` is missing: |
| 6 | |
| 7 | - **macOS / Linux**: `curl -fsSL https://d.officecli.ai/install.sh | bash` |
| 8 | - **Windows (PowerShell)**: `irm https://d.officecli.ai/install.ps1 | iex` |
| 9 | |
| 10 | Verify with `officecli --version` (open a new terminal if PATH hasn't picked up). If install fails, download a binary from https://github.com/iOfficeAI/OfficeCLI/releases. |
| 11 | |
| 12 | ## ⚠️ Help-First Rule |
| 13 | |
| 14 | **This skill teaches what good xlsx looks like, not every command flag. When a property name, enum value, or alias is uncertain, consult help BEFORE guessing.** |
| 15 | |
| 16 | ```bash |
| 17 | officecli help xlsx # List all xlsx elements |
| 18 | officecli help xlsx <element> # Full element schema (e.g. pivottable, chart, cf) |
| 19 | officecli help xlsx <verb> <element> # Verb-scoped (e.g. add chart, set cell) |
| 20 | officecli help xlsx <element> --json # Machine-readable schema |
| 21 | ``` |
| 22 | |
| 23 | Help reflects the installed CLI version. When this skill and help disagree, **help is authoritative**. |
| 24 | |
| 25 | ## Shell & Execution Discipline |
| 26 | |
| 27 | **Shell quoting (zsh / bash).** Excel paths contain `[]`, and number formats contain `$`. Both are shell metacharacters. Rules: |
| 28 | |
| 29 | - ALWAYS quote element paths: `"/Sheet1/row[1]"`, not `/Sheet1/row[1]`. |
| 30 | - Use **single quotes** for any prop value containing `$`: `numFmt='$#,##0'`. |
| 31 | - For formulas with cross-sheet `!` references, use `batch` with a `<<'EOF'` heredoc (see Known Issues). |
| 32 | - `\n` and `\t` in a prop value ARE interpreted by the CLI — `\n` is a real in-cell line break (pair with `--prop wrapText=true`), `\t` a tab — consistent across xlsx / docx / pptx. Double them (`\\n`) for a literal backslash-n (rarely wanted). (`$` is the shell layer above — single-quote it.) |
| 33 | |
| 34 | **Incremental execution.** Run commands one at a time and read each exit code. `officecli` mutates the file on every call; a 50-command script that fails at command 3 will cascade silently. One command → check output → continue. |
| 35 | |
| 36 | ## Requirements for Outputs |
| 37 | |
| 38 | Before reaching for a command, know what a good xlsx looks like. These are the deliverable standards every workbook MUST meet. |
| 39 | |
| 40 | ### All Excel files |
| 41 | |
| 42 | **Zero formula errors.** Every delivered workbook MUST have ZERO `#REF!`, `#DIV/0!`, `#VALUE!`, `#NAME?`, `#N/A`. No exceptions — guard denominators with `IFERROR` or `IF(x=0,...)`. |
| 43 | |
| 44 | **Formulas, not hardcoded values.** If a number can be computed from other cells, it is a formula. Hardcoding `5000` where `=SUM(B2:B9)` belongs breaks the contract that the workbook stays live when inputs change. This is the single most important rule in this skill. |
| 45 | |
| 46 | **Professional font.** Use one consistent, professional font across the workbook (Arial / Calibri / Times New Roman). Don't mix four fonts because one sheet came from CSV. |
| 47 | |
| 48 | **Explicit widths.** There is no auto-fit. Any column the user will read MUST have `width` set — default 8.43 chars clips everything. Sensible starts: labels 20-25, numbers 12-15, dates 12, short codes 8-10. |
| 49 | |
| 50 | **Preserve existing templates.** When editing a file that already has a look, match it. Existing conventions override these guidelines. |
| 51 | |
| 52 | ### Visual delivery floor (applies to EVERY workbook) |
| 53 | |
| 54 | Before you declare done, run `officecli view "$FILE" html` and Read the returned HTML path to confirm all of these: |
| 55 | |
| 56 | - **No `###` in any cell.** `###` means a column is too narrow for its widest value. Every column the user reads needs an explicit `width`. `###` in a delivered file is unfinished work, never "a small visual nit". |
| 57 | - **No truncated titles.** Sheet titles, section headers, long labels must fit. Widen the column or apply `wrapText=true` on the cell. |
| 58 | - **No placeholder tokens rendered as data.** `$fy$24`, `{var}`, `<TODO>`, `xxxx` must never appear in a cell, chart title, series name, or legend. These are build-time tokens that escaped replacement. |
| 59 | - **Pie / doughnut slices have distinct fill colors.** If the slices render same-colored, switch to `bar` / `column` or set `colors=...` explicitly. |
| 60 | - **No empty trailing pages / empty chart anchors.** `anchor=D2:J18` over empty source cells looks like a broken chart. |
| 61 | |
| 62 | If any of the above fails, STOP and fix before declaring done. |
| 63 | |
| 64 | **Print layout.** Any sheet the user may print or send as a board pack needs page setup. Default portrait + no fit-to-page splits wide tables and charts mid-way. Pick the fit mode by sheet shape: |
| 65 | |
| 66 | ```bash |
| 67 | # Summary / chart / dashboard sheet (small, ≤ ~40 rows): fit to a single |