Skip to content

excel ole

zmworm edited this page Apr 29, 2026 · 16 revisions

Excel: OLE Object

Embedded OLE objects (Word documents, PowerPoint decks, PDFs, Visio diagrams, etc.) stored inside a worksheet. Excel anchors each object to a cell range and always renders it as an icon preview — there is no inline "content" display mode for worksheet OLE.

Path: /{SheetName}/ole[N] (1-based, per sheet)

Aliases accepted in selectors and --type: ole, oleobject, object, embed, embeddedobject.

Operations

  • add - Embed an OLE object
  • set - Replace source, refresh ProgID, resize, or re-anchor
  • get - Read OLE object properties and optionally extract the embedded binary
  • query - Find OLE objects by selector
  • remove - Not supported yet (use raw-set or re-create the sheet)

set

Path: /{SheetName}/ole[N]

Property Accepted Values Description
src / path file path Replace the embedded payload. ProgID is auto-refreshed from the new extension unless progId is also set in the same call. Old part is deleted to avoid bloat.
progId valid ProgID Override the OLE ProgID (e.g. Word.Document.12, Excel.Sheet.12, Package).
width unit-qualified (6cm, 2in, 160pt) or integer cell count Resize horizontally. Sub-cell remainder is preserved in the to-marker ColumnOffset for round-trip fidelity.
height unit-qualified or integer cell count Resize vertically (to-marker RowOffset carries the sub-cell remainder).
anchor cell range (B2:E6) or single cell (B2) Re-anchor the object. width/height in the same call are ignored with a stderr warning (anchor defines the full rectangle).

Not supported (throws ArgumentException):

  • display — Excel always shows OLE objects as icons (no DrawAspect concept).
  • name — SpreadsheetML x:oleObject has no Name attribute in the schema.

Examples

# Replace the embedded Word document with a new one (progId auto-refreshes)
officecli set book.xlsx /Sheet1/ole[1] --prop src=updated-memo.docx

# Resize existing object
officecli set book.xlsx /Sheet1/ole[1] --prop width=8cm --prop height=5cm

# Re-anchor to a different cell range
officecli set book.xlsx /Sheet1/ole[1] --prop anchor=D4:H10

# Pin an explicit ProgID
officecli set book.xlsx /Sheet1/ole[1] --prop progId=Package

get Attributes

Canonical Format schema (shared with Word/PPT OLE where applicable):

Attribute Type Description
objectType string Always ole
progId string OLE ProgID (e.g. Word.Document.12, Excel.Sheet.12, Package)
display string Always icon for Excel (schema symmetry with Word/PPT; Excel has no content mode)
contentType string MIME type of the embedded payload
fileSize number Size of embedded binary (bytes)
width string Display width (unit-qualified, e.g. 6cm)
height string Display height (unit-qualified)
anchor string Cell-range form of the object's rectangle (e.g. B2:E6) — round-trips directly to set anchor=...
shapeId number Legacy VML shape ID (1025-based, unique per sheet)
relId string Relationship ID of the embedded part
previewImage string Path to extracted preview image when available (auto-converted EMF/WMF → PNG)
previewContentType string Preview image MIME type

Extract embedded binary

# Read properties
officecli get book.xlsx /Sheet1/ole[1]

# Extract the embedded payload to disk
officecli get book.xlsx /Sheet1/ole[1] --save extracted.docx

--save adds savedTo (path) and savedBytes (size) to the standard attributes.

query

# Find all OLE objects across every sheet
officecli query book.xlsx "ole"
officecli query book.xlsx "object"
officecli query book.xlsx "embed"

# Scope to one sheet
officecli query book.xlsx "Sheet1!ole"

# Filter by ProgID (exact or contains)
officecli query book.xlsx 'ole[progId=Excel.Sheet.12]'
officecli query book.xlsx 'ole[progId~=Word]'

# Filter by size
officecli query book.xlsx 'ole[fileSize>10000]'

view Output

OLE object count appears in view outline per sheet when present, alongside charts/pivot tables/etc. Preview images for OLE objects are surfaced via the previewImage attribute in get.

Notes

  • No remove yet — Excel OLE remove is not wired into ExcelHandler.Mutations. Work around with raw-set or rebuild the sheet.
  • Orphan parts are not indexed — embedded parts without a matching x:oleObject element are intentionally hidden from ole[N] so get/set stay in lockstep. Use validate or raw package inspection to audit them.
  • ProgID auto-detection from the source file extension (.docxWord.Document.12, .xlsxExcel.Sheet.12, .pptxPowerPoint.Show.12, .pdf/unknown → Package).
  • ProgID validation: ≤39 chars, no leading digit, valid COM characters — see OleHelper.ValidateProgId.
  • Legacy VML shape placeholder is also created for schema compliance; Office 2010+ renders from objectPr/anchor and ignores the VML fallback.
  • Resident mode (officecli open) supports add/set/get --save for OLE.

See Also


Based on OfficeCLI v1.0.64

Clone this wiki locally