Element, attribute and default lists come from the Transitional schema
dml-spreadsheetDrawing.xsd (namespace
http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing, usually prefixed
xdr) and dml-main.xsd of ECMA-376 5th edition Part 4, checked against Part 1
section 12.3.8 (the Drawings part) and 20.5 (elements 20.5.2, simple types 20.5.3). Notes marked
Excel: come from [MS-OI29500] v20260818, 2.1.1358 to 2.1.1377. The shapes,
pictures, text bodies and fills inside a drawing are ordinary DrawingML and are shared with Word and
PowerPoint; this page covers what a spreadsheet adds: where the object sits on the grid. Charts are
reached from a drawing through a graphic frame and are on the Charts page.
The drawing part
- Content type
application/vnd.openxmlformats-officedocument.drawing+xml, root elementwsDr, source relationship type.../officeDocument/2006/relationships/drawing(Part 1 12.3.8). - A drawing part is the target of an explicit relationship from a worksheet or a chart sheet, named by
the
drawingelement of that sheet (r:id). There shall be only one drawing part per worksheet or chart sheet. wsDr(CT_Drawing) holds any number, in any order, oftwoCellAnchor,oneCellAnchorandabsoluteAnchor.- The images, charts and other parts an object uses are targets of relationships in the drawing
part’s own
.relsfile (r:embedof a picture,c:chart r:idof a graphic frame). - Comments and form controls use a different, legacy mechanism (a VML part named by
legacyDrawingin the sheet); header and footer pictures uselegacyDrawingHF. Neither is inwsDr.
Anchors
Every anchor holds one object (see below) followed by a required clientData. The three
kinds differ in how the position and size are given:
| Anchor | Children in order | Meaning |
|---|---|---|
twoCellAnchor | from, to, the object, clientData; attribute editAs | The object spans from one cell position to another. |
oneCellAnchor | from, ext (cx, cy in EMU), the object, clientData | The object starts at a cell position and has an absolute size; it moves with the cell. |
absoluteAnchor | pos (x, y in EMU), ext, the object, clientData | The object sits at a fixed distance from the top left of the sheet, with an absolute size. |
from and to are markers (CT_Marker) with four children in
order: col (0-based column, an integer of 0 or more), colOff (offset into
that column in EMU), row (0-based row, 0 or more) and rowOff (EMU). Part 1
says the row number should never exceed the number of rows in the sheet. A marker is a point inside a
cell, so a picture anchored from column 1, row 2 with offsets 0 starts at the top left corner of B3.
editAs (ST_EditAs, default twoCell) says what happens when
columns or rows between or before the anchor are resized, inserted or deleted:
twoCell: move and resize with the cells (both anchors follow their cells).oneCell: move with the cell offrombut keep the size: if rows or columns are added betweenfromandtothetoanchor is moved to keep the size.absolute: keep the position and size measured from the sheet origin; if rows or columns are added before the object its anchors move to keep the same absolute position.
clientData has two Boolean attributes, both default true:
fLocksWithSheet (the object cannot be selected when the sheet is protected) and
fPrintsWithSheet (the object prints with the sheet).
Excel: in a marker, col is at most 16383 (2.1.1361) and
row at most 1048575 (2.1.1370), the last column and row of the grid, although the
standard leaves both unbounded. colOff and rowOff may be up to
27273042316900 by the standard, but Excel does not draw an object whose offset is above
20454781742437 (2.1.1362, 2.1.1371). The top left marker must be less than or equal to the bottom
right one: a twoCellAnchor whose to is left of or above its
from is not drawn (2.1.1365, 2.1.1375), although the standard allows it.
Objects
Each anchor holds exactly one of these (the group EG_ObjectChoices):
| Element | Children in order | Attributes |
|---|---|---|
sp (shape, text box) | nvSpPr (cNvPr, cNvSpPr), spPr, style, txBody | macro, textlink, fLocksText (true), fPublished (false) |
cxnSp (connector) | nvCxnSpPr (cNvPr, cNvCxnSpPr), spPr, style | macro, fPublished |
pic (picture) | nvPicPr (cNvPr, cNvPicPr), blipFill, spPr, style | macro, fPublished |
graphicFrame (chart, table, SmartArt, OLE) | nvGraphicFramePr (cNvPr, cNvGraphicFramePr), xfrm, a:graphic | macro, fPublished |
grpSp (group) | nvGrpSpPr (cNvPr, cNvGrpSpPr), grpSpPr, then any number of sp, grpSp, graphicFrame, cxnSp, pic | none |
contentPart | none | r:id (required) |
cNvPr(DrawingMLCT_NonVisualDrawingProps):id(required integer),name(required),descr(alternative text),hidden(false),title; childrenhlinkClick,hlinkHover,extLst.cNvSpPr:txBox(false) andspLocks.cNvPicPr:preferRelativeResize(true) andpicLocks.cNvCxnSpPr:cxnSpLocks,stCxn,endCxn(the shapes a connector is glued to).spPr(shape properties): the geometry (prstGeomorcustGeom), fill, line, effects, and anxfrmwithrot,flipH,flipV,offandext. The preset shape names and the geometry language are shared with the other Office formats (see the PPTX and DOCX references).graphicFramehas its ownxfrm(CT_Transform2D, a required element, withoffandext); the real position comes from the anchor. The graphic data of a chart has theurihttp://schemas.openxmlformats.org/drawingml/2006/chartand holdsc:chart r:id.contentPartrefers, byr:id, to XML content in some other format (MathML, SMIL, SVG); the relationship must be of typecustomXmland internal. A reader that cannot process it should carry on, and if possible indicate that content was not imported (20.5.2.12).textlinkon a shape links its text to a cell;macronames a macro run when the shape is clicked.
Excel:
hlinkHoverundercNvPris not supported (2.1.1359).cNvSpPrdescribes the non-visual properties of a shape, not of a connection shape as the standard’s title implies (2.1.1360).macroonsp,cxnSp,picandgraphicFramemust follow the grammar of a name reference (18.17.2.5), 0 to 256 characters (2.1.1363, 1366, 1368, 1372).textlinkmust reference a cell or a range; only the first cell of a range counts (2.1.1372 a); whentextlinkis presenttxBodyis required, although the schema makes it optional (2.1.1372 b).bwModeonspPrandgrpSpPris not supported by Excel or Word; elsewhere Office uses it to say how the object is drawn in black and white, and a value on a group applies to the children (2.1.1367, 2.1.1373).spPris used for shapes, connectors and pictures alike (2.1.1373 b). Properties inspProverride the same ones fromstyle(lnRef,effectRef,fillRef,fontRef); properties intxBodyoverridefontRef;fontRefis not used forpicandcxnSp(2.1.1374).- In
txBodyparagraphs take their style fromlstStylewhen they define none, and from the current text style when there is nolstStyleeither (2.1.1376). - The
xfrmof a graphic frame does not supportflipH,flipVorrot(values read are not written back), and itsoffandextare used only when the frame is inside a group; outside a group Excel always writes 0 for all four values (2.1.1377). blipFillfollows the notes onblipFillin 21.3.2.2 (2.1.1358).
Divergence from the standard
| Where | The standard says | What the programs do |
|---|---|---|
col, row | unbounded non-negative integers | Excel: at most 16383 and 1048575 |
colOff, rowOff | any value up to 27273042316900 | Excel does not draw the object above 20454781742437 |
from and to | no relation between them | Excel does not draw an object whose right edge is left of, or bottom edge above, its start |
macro | any string | Office: a name-reference grammar, up to 256 characters |
txBody with textlink | optional | required in Excel |
xfrm of a graphic frame | rot, flipH, flipV, off, ext apply | Excel ignores rotation and flips, and writes 0 for off and ext outside groups |
| anchor order | the three anchor kinds may be interleaved | openpyxl keeps one list per kind (twoCellAnchor, oneCellAnchor, absoluteAnchor), so the order across kinds is lost when it saves; it also unwraps mc:AlternateContent choices into those lists |
In the viewer
The viewer reads each sheet’s drawing part (and the drawing of a chart sheet) and lists every object under Features, Drawings, pictures and charts: the sheet, the kind (shape, picture, graphic frame, group, connector, content part), the name, the anchor (type and position), the relationship target and the text or alternative text. Charts are drawn as described on the Charts page. Pictures and shapes are listed, not painted on the sheet grid.
Sources
- ECMA-376 5th edition Part 1 sections 12.3.8, 20.5.2 and 20.5.3, and Part 4 Transitional
dml-spreadsheetDrawing.xsdanddml-main.xsd, in the project’s research/ooxml/ecma376/ - [MS-OI29500] v20260818, research/ooxml/ms/ (notes 2.1.1358 to 2.1.1377, lines 24181 to 24313)
- research/xlsx/programs/openpyxl_spreadsheet_drawing.py (
openpyxl/drawing/spreadsheet_drawing.py) - The viewer code explorer/formats/xlsx/book.js (
readDrawing)