Paper Office
paper-docxAPI referencetable

_Cell

paper-docx 0.2.0 API reference

Table cell.

_Cell(tc: CT_Tc, parent: TableParent)

Attributes

grid_span

attributegrid_spanint

Number of layout-grid cells this cell spans horizontally.

A "normal" cell has a grid-span of 1. A horizontally merged cell has a grid-span of 2 or more.

paragraphs

attributeparagraphs

List of paragraphs in the cell.

A table cell is required to contain at least one block-level element and end with a paragraph. By default, a new cell contains a single paragraph. Read-only

part

attributepartStoryPart

The package part containing this object.

tables

attributetables

List of tables in the cell, in the order they appear.

Read-only.

text

attributetextstr

The entire contents of this cell as a string of text.

Assigning a string to this property replaces all existing content with a single paragraph containing the assigned text in a single run.

vertical_alignment

attributevertical_alignment

Member of :ref:WdCellVerticalAlignment or None.

A value of None indicates vertical alignment for this cell is inherited. Assigning None causes any explicitly defined vertical alignment to be removed, restoring inheritance.

width

attributewidth

The width of this cell in EMU, or None if no explicit width is set.

Functions

add_paragraph

funcadd_paragraph(text: str = '', style: str | ParagraphStyle | None = None)

Return a paragraph newly added to the end of the content in this cell.

If present, text is added to the paragraph in a single run. If specified, the paragraph style style is applied. If style is not specified or is None, the result is as though the 'Normal' style was applied. Note that the formatting of text in a cell can be influenced by the table style. text can contain tab (\t) characters, which are converted to the appropriate XML form for a tab. text can also include newline (\n) or carriage return (\r) characters, each of which is converted to a line break.

paramtextstr
= ''
paramstylestr | ParagraphStyle | None
= None

add_table

funcadd_table(rows: int, cols: int) -> Table

Return a table newly added to this cell after any existing cell content.

The new table will have rows rows and cols columns.

An empty paragraph is added after the table because Word requires a paragraph element as the last element in every cell.

paramrowsint
paramcolsint

Returns

docx.table.Table

iter_inner_content

funciter_inner_content() -> Iterator[Paragraph | Table]

Generate each Paragraph or Table in this container in document order.

Returns

typing.Iterator[docx.text.paragraph.Paragraph | docx.table.Table]

merge

funcmerge(other_cell: _Cell)

Return a merged cell created by spanning the rectangular region having this cell and other_cell as diagonal corners.

Raises InvalidSpanError if the cells do not define a rectangular region.

paramother_cell_Cell

On this page