Skip to content

Tables & Lists

Tables

doc.add_table(
    headers=["Algorithm", "Best Case", "Worst Case", "Space"],
    rows=[
        ["Merge Sort", "O(n log n)", "O(n log n)", "O(n)"],
        ["Quick Sort", "O(n log n)", "O(n²)", "O(log n)"],
        ["Bubble Sort", "O(n)", "O(n²)", "O(1)"],
    ],
)

Tables are styled according to the active preset. You can also pass a custom Word table style:

doc.add_table(
    headers=["Name", "Score"],
    rows=[["Alice", "95"], ["Bob", "87"]],
    style="Light List Accent 1",
)

Bullet Lists

doc.add_bullet_list([
    "First item",
    "Second item",
    "Third item with more detail",
])

Numbered Lists

doc.add_numbered_list([
    "Clone the repository",
    "Install dependencies",
    "Run the tests",
    "Submit a pull request",
])