borders
borders
¶
The border-edge proxy objects shared by tables, cells, paragraphs and pages.
Four containers in WordprocessingML carry a set of border edges — w:tblBorders,
w:tcBorders, w:pBdr and w:pgBorders — and they differ only in which edges they
admit and where the element lives. The mapping proxy and the per-edge proxy are defined
here once so all four spell the same; each container supplies its own small subclass
naming its edges and saying how to reach its element.
_Border
¶
_Border(borders: _Borders, edge: str)
One border edge of a table, cell, paragraph or page, e.g. table.borders["top"].
A border edge that is not set has None for every property, meaning the effective
appearance of that edge is inherited from the style hierarchy. Assigning to any
property other than line on an edge that is not set creates it with a line
style of WD_LINE_STYLE.SINGLE, because a border with no line style is not valid
XML. Assigning None to line removes the edge entirely.
Source code in src/docx/borders.py
color
property
writable
¶
color: RGBColor | None
RGBColor of this border edge, or None when it has no explicit color.
As for ColorFormat, a border whose color is the automatic color reads as
None; Word chooses that color at render time, so there is no RGB value to
report.
line
property
writable
¶
line: WD_LINE_STYLE | None
Member of WdLineStyle, or None when this edge is not set.
_Borders
¶
Bases: Mapping[str, _Border]
The border edges of a table, cell, paragraph or page, keyed by edge name.
A read-only mapping in the sense that the set of keys is fixed; the _Border object each key maps to is what you assign through:
Every edge admitted by the schema is always a key, whether or not it is set, so
iterating yields edges with a _Border.line of None as well.
Edge names are the local names used in the XML. A table admits top, start,
left, bottom, end, right, insideH and insideV; a cell adds tl2br and
tr2bl; a paragraph has top, left, bottom, right, between and bar; a
page has the plain four. Word writes left and right for a left-to-right table
and start and end for a right-to-left one.