Skip to main content
Create, read and edit .xlsx workbooks, and read .docx documents and .pptx decks, on any mount. Mirage implements the commands below with OfficeCLI’s paths, output and messages.

Setup

office has no account config. It reads and writes workbooks through existing mounts.
For YAML registration, see the CLI overview.

Supported commands

Run office <command> --help for the supported flags and operands. This list is generated from Mirage’s registered command tree.

Edit a workbook

A path names the workbook (/), a sheet (/Sheet1), a cell (/Sheet1/A1 or Sheet1!A1), a range (/Sheet1/A1:C9), a row (/Sheet1/row[2]) or a comment by its place on the sheet (/Sheet1/comment[1]). get shows each cell’s value, type, font, fill, border, alignment, protection and number format, and the workbook’s and each sheet’s own properties.

Batch

The items run against one open workbook, saved once. A failure anywhere leaves the workbook as it was, unless --best-effort keeps what succeeded; --stop-on-error stops at the first failure. The JSON also comes from --input FILE or stdin.

Query

A selector names cells (cell or a column letter such as B), rows, comments or sheets, scoped to one sheet with Sheet1! or /Sheet1/. Predicates in brackets compare a property with =, !=, ~=, >, <, >= or <= and join with and, or and not(...); :contains(text), :empty and :has(formula) filter cells, [N] picks a row or comment, , joins selectors and > picks children. A row predicate on a column name reads the sheet’s table, defined or found from its header row.

Read a document or deck

A Word path names the body (/body), a paragraph (/body/p[2] or /body/p[@paraId=1A2B3C4D]), its runs, a table, row or cell (/body/tbl[1]/tr[1]/tc[2]), a section (/section[1]), a style (/styles/Heading1), a header or a footer (/header[1]). A PowerPoint path names a slide (/slide[1]), a shape (/slide[1]/shape[@id=2]), its paragraphs and runs, a table, picture, chart, group, connector or placeholder (/slide[1]/placeholder[title]), a layout or a master. get shows each node’s own properties and what it inherits, as effective.* keys with the layer each came from in .src. A query selector names an element such as paragraph, run, table, cell, picture, style, slide or shape, with the same predicates, :contains(text) and :empty.

Differences from OfficeCLI

  • create, set and remove take .xlsx workbooks only; .docx and .pptx files take get, query and batch items that read.
  • An equation’s text is plain, not LaTeX, and a chart in a deck shows its frame and name but not its plot properties.
  • A Word query reads paragraphs, runs, tables, rows, cells, pictures, hyperlinks, bookmarks, equations, content controls, sections, headers, footers and styles. A PowerPoint query returns no comments, OLE objects, zooms, 3D models or animations.
  • A document part that is not well-formed XML reads as absent, where OfficeCLI refuses the file.
  • A formula is stored without a computed value, and Excel calculates it on open. A formula cell with no stored value shows #OCLI_NOTEVAL! and evaluated=false.
  • create writes a blank workbook with no document properties or theme.
  • set takes the props above; overwriting the first cell of a shared formula is refused.
  • query reads cells, rows, comments and sheets; charts, tables, pivot tables and other elements return no matches.
  • batch runs get, query, set and remove items.
  • Usage errors and --help use Mirage’s wording. Messages that name the command say office.