CT_Tc
paper-docx 0.2.0 API reference
w:tc table cell element.
Attributes
add_p
attributeadd_pCallable[[], CT_P]bottom
attributebottomintThe row index that marks the bottom extent of the vertical span of this cell.
This is one greater than the index of the bottom-most row of the span, similar to how a slice of the cell's rows would be specified.
get_or_add_tcPr
attributeget_or_add_tcPrCallable[[], CT_TcPr]grid_offset
attributegrid_offsetintStarting offset of tc in the layout-grid columns of its table.
A cell in the leftmost grid-column has offset 0.
grid_span
attributegrid_spanintThe integer number of columns this cell spans.
Determined by ./w:tcPr/w:gridSpan/@val, it defaults to 1.
inner_content_elements
attributeinner_content_elementslist[CT_P | CT_Tbl]Generate all w:p and w:tbl elements in this document-body.
Elements appear in document order. Elements shaded by nesting in a w:ins or
other "wrapper" element will not be included.
left
attributeleftintThe grid column index at which this <w:tc> element appears.
p
attributep= OneOrMore('w:p')p_lst
attributep_lstlist[CT_P]right
attributerightintThe grid column index that marks the right-side extent of the horizontal span of this cell.
This is one greater than the index of the right-most column of the span, similar to how a slice of the cell's columns would be specified.
tbl
attributetbl= OneOrMore('w:tbl')tbl_lst
attributetbl_lstlist[CT_Tbl]tcPr
attributetcPrCT_TcPr | None= ZeroOrOne('w:tcPr')top
attributetopintThe top-most row index in the vertical span of this cell.
vMerge
attributevMergestr | NoneValue of ./w:tcPr/w:vMerge/@val, None if w:vMerge is not present.
width
attributewidthLength | NoneEMU length represented in ./w:tcPr/w:tcW or None if not present.
xml
attributexmlstrXML string for this element, suitable for testing purposes.
Pretty printed for readability and without an XML declaration at the top.
Functions
clear_content
funcclear_content()Remove all content elements, preserving w:tcPr element if present.
Note that this leaves the w:tc element in an invalid state because it doesn't
contain at least one block-level element. It's up to the caller to add a
w:pchild element as the last content element.
first_child_found_in
funcfirst_child_found_in(*tagnames: str) -> _Element | NoneFirst child with tag in tagnames, or None if not found.
paramtagnamesstr= ()Returns
lxml.etree._Element | Noneinsert_element_before
funcinsert_element_before(elm: ElementBase, *tagnames: str)paramelmElementBaseparamtagnamesstr= ()iter_block_items
funciter_block_items()Generate a reference to each of the block-level content elements in this cell, in the order they appear.
merge
funcmerge(other_tc: CT_Tc) -> CT_TcReturn top-left w:tc element of a new span.
Span is formed by merging the rectangular region defined by using this tc
element and other_tc as diagonal corners.
paramother_tcCT_TcReturns
docx.oxml.table.CT_Tcnew
funcnew() -> CT_TcA new w:tc element, containing an empty paragraph as the required EG_BlockLevelElt.
Returns
docx.oxml.table.CT_Tcremove_all
funcremove_all(*tagnames: str) -> NoneRemove child elements with tagname (e.g. "a:p") in tagnames.
paramtagnamesstr= ()Returns
Nonexpath
funcxpath(xpath_str: str) -> AnyOverride of lxml _Element.xpath() method.
Provides standard Open XML namespace mapping (nsmap) in centralized location.
paramxpath_strstrReturns
typing.Any