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 | NoneRead/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
attributeautofitboolTrue 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
attributepartStoryPartThe 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
attributetableProvide 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 | NoneMember 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.
paramwidthLengthadd_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_idxintparamcol_idxintReturns
docx.table._Cellcolumn_cells
funccolumn_cells(column_idx: int) -> list[_Cell]Sequence of cells in the column at column_idx in this table.
paramcolumn_idxintReturns
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_idxintReturns
list[docx.table._Cell]