Skip to content

excel picture add

zmworm edited this page Apr 29, 2026 · 52 revisions

Excel: Picture - add

Add an embedded image to a worksheet.

Path: /{SheetName}

Properties

Property Default Description
path / src (required) Image source: local file path, data:image/png;base64,... data URI, or https://... HTTP URL
x 0 Horizontal position (EMU or column index)
y 0 Vertical position (EMU or row index)
width 5 Image width (EMU or pixels). Bare integers exceeding the sheet's column max are treated as EMU.
height 5 Image height (EMU or pixels). Bare integers exceeding the sheet's row max are treated as EMU.
alt / altText Alt text description
title Picture title (xdr:cNvPr@title, distinct from alt text)
name Picture {id} Override the auto-generated picture name (xdr:cNvPr@name)
rotation 0 Rotation in degrees (±angles with wraparound; stored as 60000ths of a degree)
flip / flipH / flipV / flipBoth - Flip: `flip=h
cropLeft / cropRight / cropTop / cropBottom 0 Crop insets (percent, 0-100) — aliases for the dotted-path variants
anchor - Cell-range anchor: A1:E10 (spans the range) or A1 (single-cell top-left). Alternative to x/y/width/height.
fallback 1×1 transparent PNG Raster fallback image for SVG (used by older Office versions)

Examples

officecli add data.xlsx /Sheet1 --type picture --prop src=logo.png --prop x=1 --prop y=1
officecli add data.xlsx /Sheet1 --type picture --prop src=chart.png --prop x=5 --prop y=10 --prop width=400 --prop height=300
officecli add data.xlsx /Sheet1 --type picture --prop src=photo.jpg --prop x=0 --prop y=0 --prop alt="Company Logo"

# Add picture from base64 data URI
officecli add data.xlsx /Sheet1 --type picture --prop "path=data:image/png;base64,iVBORw0KGgo..." --prop x=1 --prop y=1

# Add picture from HTTP URL
officecli add data.xlsx /Sheet1 --type picture --prop src=https://example.com/chart.png --prop x=1 --prop y=5 --prop width=400 --prop height=300

Add SVG image

officecli add data.xlsx /Sheet1 --type picture --prop src=diagram.svg --prop x=1 --prop y=1

Add SVG with custom raster fallback

officecli add data.xlsx /Sheet1 --type picture --prop src=icon.svg --prop fallback=icon.png --prop x=1 --prop y=1


> **Note:** Supported image formats: png, jpg, gif, bmp, tiff, emf, wmf, svg. HTTP URLs have a 30s timeout. SVG images use OOXML dual representation: modern Office (2016+) renders the SVG; older versions fall back to a PNG (auto-generated 1×1 transparent pixel unless `fallback` is specified).

---
*Based on OfficeCLI v1.0.64*

Clone this wiki locally