MCPcopy Index your code
hub / github.com/python-openxml/python-docx / add_table

Method add_table

src/docx/blkcntnr.py:61–72  ·  view source on GitHub ↗

Return table of `width` having `rows` rows and `cols` columns. The table is appended appended at the end of the content in this container. `width` is evenly distributed between the table columns.

(self, rows: int, cols: int, width: Length)

Source from the content-addressed store, hash-verified

59 return paragraph
60
61 def add_table(self, rows: int, cols: int, width: Length) -> Table:
62 """Return table of `width` having `rows` rows and `cols` columns.
63
64 The table is appended appended at the end of the content in this container.
65
66 `width` is evenly distributed between the table columns.
67 """
68 from docx.table import Table
69
70 tbl = CT_Tbl.new_tbl(rows, cols, width)
71 self._element._insert_tbl(tbl) # pyright: ignore[reportPrivateUsage]
72 return Table(tbl, self)
73
74 def iter_inner_content(self) -> Iterator[Paragraph | Table]:
75 """Generate each `Paragraph` or `Table` in this container in document order."""

Callers

nothing calls this directly

Calls 2

TableClass · 0.90
new_tblMethod · 0.80

Tested by

no test coverage detected