Paper Office
paper-docxAPI referencetable

Table

paper-docx 0.2.0 API reference

Proxy class for a WordprocessingML <w:tbl> element.

Table(tbl: CT_Tbl, parent: t.ProvidesStoryPart)

Attributes

alignment

attributealignmentWD_TABLE_ALIGNMENT | None

Read/write.

A member of :ref:WdRowAlignment or None, specifying the positioning of this table between the page margins. None if no setting is specified, causing the effective value to be inherited from the style hierarchy.

autofit

attributeautofitbool

True if column widths can be automatically adjusted to improve the fit of cell contents.

False if table layout is fixed. Column widths are adjusted in either case if total column width exceeds page width. Read/write boolean.

columns

attributecolumns

_Columns instance representing the sequence of columns in this table.

part

attributepartStoryPart

The package part containing this object.

rows

attributerows_Rows

_Rows instance containing the sequence of rows in this table.

style

attributestyle_TableStyle | None

_TableStyle object representing the style applied to this table.

Read/write. The default table style for the document (often Normal Table) is returned if the table has no directly-applied style. Assigning None to this property removes any directly-applied table style causing it to inherit the default table style of the document.

Note that the style name of a table style differs slightly from that displayed in the user interface; a hyphen, if it appears, must be removed. For example, Light Shading - Accent 1 becomes Light Shading Accent 1.

table

attributetable

Provide child objects with reference to the Table object they belong to, without them having to know their direct parent is a Table object.

This is the terminus of a series of parent._table calls from an arbitrary child through its ancestors.

table_direction

attributetable_directionWD_TABLE_DIRECTION | None

Member of :ref:WdTableDirection indicating cell-ordering direction.

For example: WD_TABLE_DIRECTION.LTR. None indicates the value is inherited from the style hierarchy.

Functions

add_column

funcadd_column(width: Length)

Return a _Column object of width, newly added rightmost to the table.

paramwidthLength

add_row

funcadd_row()

Return a _Row instance, newly added bottom-most to the table.

cell

funccell(row_idx: int, col_idx: int) -> _Cell

_Cell at row_idx, col_idx intersection.

(0, 0) is the top, left-most cell.

paramrow_idxint
paramcol_idxint

Returns

docx.table._Cell

column_cells

funccolumn_cells(column_idx: int) -> list[_Cell]

Sequence of cells in the column at column_idx in this table.

paramcolumn_idxint

Returns

list[docx.table._Cell]

row_cells

funcrow_cells(row_idx: int) -> list[_Cell]

DEPRECATED: Use table.rows[row_idx].cells instead.

Sequence of cells in the row at row_idx in this table.

paramrow_idxint

Returns

list[docx.table._Cell]

On this page