docx_parser_converter.docx_parsers.tables.table_cell_properties_parser module

class docx_parser_converter.docx_parsers.tables.table_cell_properties_parser.TableCellPropertiesParser[source]

Bases: object

A parser for extracting table cell properties from an XML element.

static extract_cell_merge(element: Element | None) str | None[source]

Extracts cell merge from the given XML element.

Parameters:

element (Optional[etree.Element]) – The XML element.

Returns:

The cell merge value, or None if not found.

Return type:

Optional[str]

Example

The following is an example of a cell merge element:

<w:cellMerge w:val="restart"/>
static extract_grid_span(element: Element | None) int | None[source]

Extracts grid span from the given XML element.

Parameters:

element (Optional[etree.Element]) – The XML element.

Returns:

The grid span value, or None if not found.

Return type:

Optional[int]

Example

The following is an example of a grid span element:

<w:gridSpan w:val="2"/>
static extract_hide_mark(element: Element | None) bool | None[source]

Extracts hide mark from the given XML element.

Parameters:

element (Optional[etree.Element]) – The XML element.

Returns:

True if the hide mark is found, otherwise None.

Return type:

Optional[bool]

Example

The following is an example of a hide mark element:

<w:hideMark/>
static extract_table_cell_margins(element: Element | None) dict | None[source]

Extracts table cell margins from the given XML element.

Parameters:

element (Optional[etree.Element]) – The XML element.

Returns:

The table cell margins, or None if not found.

Return type:

Optional[dict]

Example

The following is an example of table cell margins:

<w:tcMar>
    <w:top w:w="100" w:type="dxa"/>
    <w:left w:w="100" w:type="dxa"/>
    <w:bottom w:w="100" w:type="dxa"/>
    <w:right w:w="100" w:type="dxa"/>
</w:tcMar>
static extract_table_cell_width(element: Element | None) TableWidth | None[source]

Extracts table cell width from the given XML element.

Parameters:

element (Optional[etree.Element]) – The XML element.

Returns:

The table cell width, or None if not found.

Return type:

Optional[TableWidth]

Example

The following is an example of a table cell width element:

<w:tcW w:w="5000" w:type="dxa"/>
static extract_text_direction(element: Element | None) str | None[source]

Extracts text direction from the given XML element.

Parameters:

element (Optional[etree.Element]) – The XML element.

Returns:

The text direction, or None if not found.

Return type:

Optional[str]

Example

The following is an example of a text direction element:

<w:textDirection w:val="btLr"/>
static extract_vertical_alignment(element: Element | None) str | None[source]

Extracts vertical alignment from the given XML element.

Parameters:

element (Optional[etree.Element]) – The XML element.

Returns:

The vertical alignment, or None if not found.

Return type:

Optional[str]

Example

The following is an example of a vertical alignment element:

<w:vAlign w:val="center"/>
static parse(tcPr_element: Element | None) TableCellProperties[source]

Parses table cell properties from the given XML element.

Parameters:

tcPr_element (Optional[etree.Element]) – The cell properties XML element.

Returns:

The parsed table cell properties.

Return type:

TableCellProperties

Example

The following is an example of table cell properties in a table cell element:

<w:tcPr>
    <w:tcW w:w="5000" w:type="dxa"/>
    <w:tcBorders>
        <w:top w:val="single" w:sz="4" w:space="0" w:color="000000"/>
        <w:left w:val="single" w:sz="4" w:space="0" w:color="000000"/>
        <w:bottom w:val="single" w:sz="4" w:space="0" w:color="000000"/>
        <w:right w:val="single" w:sz="4" w:space="0" w:color="000000"/>
    </w:tcBorders>
    <w:shd w:val="clear" w:color="auto" w:fill="FFFF00"/>
    <w:tcMar>
        <w:top w:w="100" w:type="dxa"/>
        <w:left w:w="100" w:type="dxa"/>
        <w:bottom w:w="100" w:type="dxa"/>
        <w:right w:w="100" w:type="dxa"/>
    </w:tcMar>
    <w:textDirection w:val="btLr"/>
    <w:vAlign w:val="center"/>
    <w:gridSpan w:val="2"/>
</w:tcPr>