Skip to content

command query excel

zmworm edited this page Apr 4, 2026 · 28 revisions

query - Excel (.xlsx)

Query selectors for Excel documents.

Element Selectors

Selector Description
cell Cells
row Rows
sheet Sheets
validation Data validations
comment / note Comments
table / listobject Tables
chart Charts
pivottable / pivot Pivot tables
Column letters (A, B, AB) Cells in specific column

Cell Attributes

Attribute Description
value Exact value match
type String, Number, Boolean
type!=value Exclude cells of a given type
formula true / false
empty true / false
font.bold Format attribute filter (e.g., cell[font.bold=true])
numberformat Format attribute filter (e.g., cell[numberformat=0.00])

Filter Operators

Operator Meaning Example
[attr] Exists (present and non-empty) [formula]
= Exact match [style=Heading1]
!= Not equal [font!=Arial]
~= Contains text [text~=quarterly]
>= Greater or equal (numeric) [size>=24pt]
<= Less or equal (numeric) [size<=12pt]

Notes:

  • Can combine: cell[font.bold=true][font.size>=14pt]
  • Color-aware: [fill=#FF0000] matches [fill=FF0000]
  • Dimension-aware: compares 2cm vs 1in correctly
  • Special keys text and type match node content and type
  • \!= accepted for zsh compatibility
  • Malformed selectors (unclosed brackets, empty [], invalid operators) now throw an error with suggestions instead of silently returning empty results

Pseudo-Selectors

Selector Description
:contains("text") Cell contains text
:empty Cell is empty
:has(formula) Cell has a formula

Shorthand: :text is equivalent to :contains("text") -- e.g., pivot:Sales matches pivot tables whose name contains "Sales".

Sheet Prefix

Filter by sheet: Sheet1!cell[value="100"]

Examples

# 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"

# Column B non-zero values
officecli query data.xlsx "B[value!=0]"

# String-type cells
officecli query data.xlsx "cell[type=String]"

# Formulas in specific sheet
officecli query data.xlsx "Sheet2!cell[formula=true]"

# All comments
officecli query data.xlsx "comment"

# All tables
officecli query data.xlsx "table"

# All pivot tables
officecli query data.xlsx "pivottable"

# Pivot tables containing "Sales" in name
officecli query data.xlsx 'pivot:contains("Sales")'

# Shorthand form
officecli query data.xlsx "pivot:Sales"

# Bold cells
officecli query data.xlsx "cell[font.bold=true]"

# Cells with specific number format
officecli query data.xlsx "cell[numberformat=0.00]"

# Not-equal filter
officecli query data.xlsx "cell[type!=String]"

# Cells with font size >= 14pt
officecli query data.xlsx "cell[font.size>=14pt]"

# Cells with gradient fill
officecli query data.xlsx "cell[fill~=gradient]"

# Cells that have a formula
officecli query data.xlsx "cell[formula]"

See Also


Based on OfficeCLI v1.0.33

Clone this wiki locally