8000 Add automatically merging cells in tables · Issue #970 · py-pdf/fpdf2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Add automatically merging cells in tables #970
@stevenlis

Description

@stevenlis

Please explain your intent
It is common to encounter merged cells in a table. Currently, you need to manually create a merged cell using colspan in row.cell(). It would be helpful if merged cells could be handled automatically, eliminating the need to loop over your data and add multiple nested if-else conditions.

Describe the solution you'd like
Assuming our table data appears as follows.

table_data = [
    ['0', '1', '2', '3'],
    ['A1', 'A2', '-', 'A4'],
    ['B1', '-', 'B3', 'B4'],
]

Here, we use '-' (or any other user-defined placeholder) to indicate an empty cell.

  • Empty cells can be merged with the cell before:
with pdf.table(width=120, auto_merging='before', empty_cell='-') as table

CS-zwUA0SLZ@2x

  • Or they can be merged with the cell after:
with pdf.table(width=120, auto_merging='after', empty_cell='-') as table

CS-hMdlh819@2x

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0