Skip to content

Table cells should support recursively add_table with style #1285

Open
@qzhua

Description

@qzhua

In the member function of Table._Cell

    def add_table(self, rows, cols):
        """Return a table newly added to this cell after any existing cell content,
        having `rows` rows and `cols` columns.

        An empty paragraph is added after the table because Word requires a paragraph
        element as the last element in every cell.
        """
        width = self.width if self.width is not None else Inches(1)
        table = super(_Cell, self).add_table(rows, cols, width)
        self.add_paragraph()

It would be nice if this function can support a style parameter.
Now we have to write code like this:

        word_table = cell.add_table(rows=0, cols=num_cols)
        word_table.autofit = True
        word_table.style = 'Table Grid'

What we want is :

        word_table = cell.add_table(rows=0, cols=num_cols, style = 'Table Grid')
        word_table.autofit = True

which would be consistent with the Document class

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions