Paper Office
paper-docxAPI referenceoxml.table

CT_Tc

paper-docx 0.2.0 API reference

w:tc table cell element.

Attributes

add_p

attributeadd_pCallable[[], CT_P]

bottom

attributebottomint

The 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_offsetint

Starting offset of tc in the layout-grid columns of its table.

A cell in the leftmost grid-column has offset 0.

grid_span

attributegrid_spanint

The 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

attributeleftint

The grid column index at which this <w:tc> element appears.

p

attributep
= OneOrMore('w:p')

p_lst

attributep_lstlist[CT_P]
attributerightint

The 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

attributetopint

The top-most row index in the vertical span of this cell.

vMerge

attributevMergestr | None

Value of ./w:tcPr/w:vMerge/@val, None if w:vMerge is not present.

width

attributewidthLength | None

EMU length represented in ./w:tcPr/w:tcW or None if not present.

xml

attributexmlstr

XML 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 | None

First child with tag in tagnames, or None if not found.

paramtagnamesstr
= ()

Returns

lxml.etree._Element | None

insert_element_before

funcinsert_element_before(elm: ElementBase, *tagnames: str)
paramelmElementBase
paramtagnamesstr
= ()

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_Tc

Return 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_Tc

Returns

docx.oxml.table.CT_Tc

new

funcnew() -> CT_Tc

A new w:tc element, containing an empty paragraph as the required EG_BlockLevelElt.

Returns

docx.oxml.table.CT_Tc

remove_all

funcremove_all(*tagnames: str) -> None

Remove child elements with tagname (e.g. "a:p") in tagnames.

paramtagnamesstr
= ()

Returns

None

xpath

funcxpath(xpath_str: str) -> Any

Override of lxml _Element.xpath() method.

Provides standard Open XML namespace mapping (nsmap) in centralized location.

paramxpath_strstr

Returns

typing.Any

On this page