_Body
paper-docx 0.2.0 API reference
Proxy for <w:body> element in this document.
It's primary role is a container for document content.
_Body(body_elm: CT_Body, parent: t.ProvidesStoryPart)Attributes
paragraphs
attributeparagraphsA list containing the paragraphs in this container, in document order.
Read-only.
part
attributepartStoryPartThe package part containing this object.
tables
attributetablesA list containing the tables in this container, in document order.
Read-only.
Functions
add_paragraph
funcadd_paragraph(text: str = '', style: str | ParagraphStyle | None = None) -> ParagraphReturn paragraph newly added to the end of the content in this container.
The paragraph has text in a single run if present, and is given paragraph
style style.
If style is None, no paragraph style is applied, which has the same effect
as applying the 'Normal' style.
paramtextstr= ''paramstylestr | ParagraphStyle | None= NoneReturns
docx.text.paragraph.Paragraphadd_table
funcadd_table(rows: int, cols: int, width: Length) -> TableReturn 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.
paramrowsintparamcolsintparamwidthLengthReturns
docx.table.Tableclear_content
funcclear_content() -> _BodyReturn this _Body instance after clearing it of all content.
Section properties for the main document story, if present, are preserved.
Returns
docx.document._Bodyiter_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]