Skip to content

excel column

goworm edited this page Jun 28, 2026 · 1 revision

Excel: Column

Address a worksheet column to set its width, hide it, group it into an outline, apply a column-wide number format, or query columns.

Path: /{SheetName}/col[X] (X is a column letter A, B, … or a 1-based index)

Operations

  • add - Insert a column, optionally at a given letter or cloned from another column
  • set - Change width, visibility, outline grouping, number format, or auto-fit
  • get - Read a column's attributes
  • query - Find columns (query column)
  • remove - Delete a column

add

Parent: /{SheetName}

Property Default Description
name Column letter to insert at (e.g. C). If omitted, uses index position or appends. Used only for addressing
width Column width in Excel character units (bare number or unit-qualified)
hidden false Hide the column

add --from /{SheetName}/col[L] with --before/--after clones cells + single-column mergeCells; relative formula refs are delta-shifted to the new anchor (Excel "Insert Copied Cells" parity). Inserting at an occupied slot shifts every column at or past the slot right by one, and every range-bearing structure on the sheet (mergeCells, CF/DV sqref, autoFilter, hyperlink/table refs, named ranges, formula cell-refs) follows the displacement.

set

Path: /{SheetName}/col[X]

Property Description
width Column width in Excel character units
hidden Hide/show the column
outline Outline/group level 0-7. Aliases: outlineLevel, group. Set-only
collapsed Collapse the column group (set-only)
numberformat Excel format code applied to the whole column via a style ref on col@s (number, date, percentage, currency, text @). Aliases: numfmt, format. Mirrors cell-level numberformat
autofit Auto-fit width to cell content (set-only by design — meaningless at Add since a new column has no data)

get Attributes

Attribute Type Description
width number Column width (raw double, character units)
hidden bool true when hidden, key absent otherwise
numberformat string Format string as stored (resolved via the column's style index)
customWidth bool true when the column has an explicit width (not the sheet default). Mirrors OOXML col@customWidth

Examples

# Set a fixed column width
officecli set data.xlsx /Sheet1/col[A] --prop width=20

# Auto-fit one column, or every column on the sheet
officecli set data.xlsx /Sheet1/col[A] --prop autofit=true
officecli set data.xlsx /Sheet1 --prop autoFit=true

# Hide a column
officecli set data.xlsx /Sheet1/col[C] --prop hidden=true

# Apply a column-wide number format
officecli set data.xlsx /Sheet1/col[B] --prop numberformat="#,##0.00"
officecli set data.xlsx /Sheet1/col[D] --prop numberformat=yyyy-mm-dd

# Group columns into an outline level, then collapse
officecli set data.xlsx /Sheet1/col[B] --prop outline=1
officecli set data.xlsx /Sheet1/col[B] --prop collapsed=true

# Insert a new column at letter C
officecli add data.xlsx /Sheet1 --type column --prop name=C

# Clone a column's cells and formatting after the original
officecli add data.xlsx /Sheet1/col[B] --from /Sheet1/col[B] --after

# Read a column's attributes
officecli get data.xlsx /Sheet1/col[A]

# Remove a column
officecli remove data.xlsx /Sheet1/col[C]

See Also

  • Sheet - The parent worksheet
  • Row - The row counterpart (height, hide, outline)
  • Cell - Individual cells; numberformat also applies per-cell
  • Column Break - Manual vertical page breaks
  • Excel Reference - All Excel elements

Based on OfficeCLI v1.0.124

Clone this wiki locally