Skip to content

Phase D.13: Insert paragraph/table at arbitrary position #26

@loadfix

Description

@loadfix

Add ability to insert paragraphs and tables at specific positions. Upstream python-openxml#156 (23 comments).

API Design

  • paragraph.insert_paragraph_after(text, style) — insert a new paragraph after this one
  • paragraph.insert_paragraph_before() already exists — verify it works correctly
  • paragraph.insert_table_after(rows, cols) — insert a table after this paragraph
  • table.insert_paragraph_after(text, style) — insert after a table
  • body.insert_element_before(new_element, reference_element) — low-level

Implementation

Uses lxml's addnext()/addprevious() on the underlying elements. The high-level methods create the element and position it.

Upstream issue: python-openxml#156

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentTriggers the developer agentenhancementNew feature or requestphase-dQuality of Life

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions