Skip to content

Deleting a column in a simple table breaks cell alignment #1500

Open
@Frolfast

Description

@Frolfast

In python-docx, attempting to delete a column from a simple table (created via python-docx itself) causes cell misalignment or destruction of the table structure.

Environment:

  • No merged cells
  • No nested elements
  • Uniform number of columns in all rows
  • Tables created with docx.Document().add_table()

Steps to reproduce:

  1. Create a 5-column table
  2. Populate with plain text
  3. Attempt to remove column 3 using:
    row._tr.remove(row.cells[2]._tc)

Result:

  • Table becomes malformed
  • Some rows have fewer cells
  • In MS Word, rendering is broken

Expected:

  • Clean removal of the column with remaining structure preserved

This seems to be a long-standing limitation, but it now affects even simple programmatically generated documents. Please consider addressing this bug or documenting a safe workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions