Skip to content

excel sparkline

zmworm edited this page Apr 18, 2026 · 31 revisions

Excel: Sparkline

Inline mini-charts embedded within worksheet cells. Sparklines visualize data trends in a compact, single-cell format. Three types are supported: line (default), column, and stacked (win/loss). Each sparkline belongs to a sparkline group that controls its type, colors, and marker visibility.

Path: /{SheetName}/sparkline[N]

Operations

  • add - Insert a sparkline group
  • get - Read sparkline properties
  • set - Modify sparkline properties
  • remove - Delete a sparkline group
  • query - List sparklines on a sheet

Property reference

Core properties

Property Default Notes
cell (required) Target cell for the sparkline (e.g. F1). Read-only after creation
range (required) Data source range (e.g. A1:E1). Alias: data. Read-only after creation
type line line, column, stacked

Series color

Property Default Notes
color #4472C4 Main sparkline color (hex RGB)
negativecolor -- Color for negative value segments

Point visibility flags

Boolean flags that toggle highlighting of specific data points. When enabled, the corresponding marker color property controls the highlight color.

Property Default Notes
markers false Show all data point markers (line type only)
highpoint false Highlight the highest data point
lowpoint false Highlight the lowest data point
firstpoint false Highlight the first data point
lastpoint false Highlight the last data point
negative false Highlight negative data points

Marker colors (Add only)

These properties set the color of highlighted data points. Currently supported during add but not set.

Property Default Notes
highmarkercolor -- Color for the high point marker
lowmarkercolor -- Color for the low point marker
firstmarkercolor -- Color for the first point marker
lastmarkercolor -- Color for the last point marker
markerscolor -- Color for all data point markers

Line weight

Property Default Notes
lineweight -- Line thickness in points (line type only)

get

Returns a DocumentNode with the sparkline group's properties in .Format.

officecli get data.xlsx /Sheet1/sparkline[1]

Returned format keys:

Key Value Example
type line, column, stacked line
color #-prefixed hex #4472C4
negativeColor #-prefixed hex (when set) #FF0000
markers true (only present when enabled) true
highPoint true (only present when enabled) true
lowPoint true (only present when enabled) true
firstPoint true (only present when enabled) true
lastPoint true (only present when enabled) true
negative true (only present when enabled) true
lineWeight numeric 1.5
cell cell reference F1
range data range (sheet prefix stripped) A1:E1

set

Modify an existing sparkline group's properties.

# Change type to column
officecli set data.xlsx /Sheet1/sparkline[1] --prop type=column

# Update series color
officecli set data.xlsx /Sheet1/sparkline[1] --prop color=FF6600

# Enable markers and highlight points
officecli set data.xlsx /Sheet1/sparkline[1] \
  --prop markers=true \
  --prop highpoint=true \
  --prop lowpoint=true

# Set negative color and enable negative highlight
officecli set data.xlsx /Sheet1/sparkline[1] \
  --prop negativecolor=FF0000 \
  --prop negative=true

# Adjust line weight
officecli set data.xlsx /Sheet1/sparkline[1] --prop lineweight=2.5

# Disable markers
officecli set data.xlsx /Sheet1/sparkline[1] --prop markers=false

Supported set properties:

Property Accepted values
type line, column, stacked
color hex RGB (e.g. 4472C4, #FF0000)
negativecolor hex RGB
markers true / false
highpoint true / false
lowpoint true / false
firstpoint true / false
lastpoint true / false
negative true / false
lineweight number (points)

Note: Marker color properties (highmarkercolor, lowmarkercolor, etc.) are currently only supported during add, not set.

query

List all sparklines on a sheet or across the workbook.

# All sparklines on Sheet1
officecli query data.xlsx sparkline --sheet Sheet1

# All sparklines in the workbook
officecli query data.xlsx sparkline

remove

Remove a sparkline group. If it is the last group in the sheet's extension, the empty extension element is cleaned up automatically.

officecli remove data.xlsx /Sheet1/sparkline[1]

HTML preview

Sparklines are not rendered in the officecli view <file> html preview.

Examples

# Create a worksheet with data and sparklines
officecli add data.xlsx / --type sheet --prop name=Sales

# Populate data
officecli set data.xlsx /Sales/A1 --prop value=10
officecli set data.xlsx /Sales/B1 --prop value=25
officecli set data.xlsx /Sales/C1 --prop value=15
officecli set data.xlsx /Sales/D1 --prop value=30
officecli set data.xlsx /Sales/E1 --prop value=20

# Add a basic line sparkline
officecli add data.xlsx /Sales --type sparkline \
  --prop cell=F1 --prop range=A1:E1

# Add a column sparkline with custom color
officecli add data.xlsx /Sales --type sparkline \
  --prop cell=F2 --prop range=A2:E2 \
  --prop type=column --prop color=ED7D31

# Add a stacked (win/loss) sparkline
officecli add data.xlsx /Sales --type sparkline \
  --prop cell=F3 --prop range=A3:E3 \
  --prop type=stacked --prop color=70AD47

# Add a line sparkline with all markers and highlight colors
officecli add data.xlsx /Sales --type sparkline \
  --prop cell=F4 --prop range=A4:E4 \
  --prop markers=true --prop markerscolor=4472C4 \
  --prop highpoint=true --prop highmarkercolor=FF0000 \
  --prop lowpoint=true --prop lowmarkercolor=0000FF \
  --prop firstpoint=true --prop firstmarkercolor=70AD47 \
  --prop lastpoint=true --prop lastmarkercolor=FFC000

# Add sparkline with negative value highlighting
officecli add data.xlsx /Sales --type sparkline \
  --prop cell=F5 --prop range=A5:E5 \
  --prop negativecolor=FF0000 --prop negative=true

# Add a thicker line sparkline
officecli add data.xlsx /Sales --type sparkline \
  --prop cell=F6 --prop range=A6:E6 \
  --prop lineweight=2.5

# Read back sparkline properties
officecli get data.xlsx /Sales/sparkline[1]

# Modify: switch to column type
officecli set data.xlsx /Sales/sparkline[1] --prop type=column

# Remove a sparkline
officecli remove data.xlsx /Sales/sparkline[3]

See Also


Based on OfficeCLI v1.0.52

Clone this wiki locally