docx_parser_converter.docx_parsers.tables.table_cell_parser module

class docx_parser_converter.docx_parsers.tables.table_cell_parser.TableCellParser[source]

Bases: object

A parser for extracting table cells from an XML element.

static parse(cell_element: Element) TableCell[source]

Parses a table cell from the given XML element.

Parameters:

cell_element (etree.Element) – The cell XML element.

Returns:

The parsed table cell.

Return type:

TableCell

Example

The following is an example of a table cell element in a document.xml file:

<w:tc>
    <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>
    <w:p>
        <!-- Paragraph content here -->
    </w:p>
</w:tc>