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

Method add_section

src/docx/document.py:140–148  ·  view source on GitHub ↗

Return a |Section| object newly added at the end of the document. The optional `start_type` argument must be a member of the :ref:`WdSectionStart` enumeration, and defaults to ``WD_SECTION.NEW_PAGE`` if not provided.

(self, start_type: WD_SECTION = WD_SECTION.NEW_PAGE)

Source from the content-addressed store, hash-verified

138 return run.add_picture(image_path_or_stream, width, height)
139
140 def add_section(self, start_type: WD_SECTION = WD_SECTION.NEW_PAGE):
141 """Return a |Section| object newly added at the end of the document.
142
143 The optional `start_type` argument must be a member of the :ref:`WdSectionStart`
144 enumeration, and defaults to ``WD_SECTION.NEW_PAGE`` if not provided.
145 """
146 new_sectPr = self._element.body.add_section_break()
147 new_sectPr.start_type = start_type
148 return Section(new_sectPr, self._part)
149
150 def add_table(self, rows: int, cols: int, style: str | _TableStyle | None = None):
151 """Add a table having row and column counts of `rows` and `cols` respectively.

Calls 2

SectionClass · 0.90
add_section_breakMethod · 0.80

Tested by 1

it_can_add_a_sectionMethod · 0.76