Reputation: 83
I have been faced with problem: How to merge some cells into big cell (vertically or horizontally merging) with python-pptx library?
I've found no examples to do this and I need some help.
Any help would be appreciated.
Upvotes: 2
Views: 2684
Reputation: 28903
Update: Cell Merge was added to python-pptx
in version 0.6.14. The method is documented here:
https://python-docx.readthedocs.io/en/latest/api/table.html#docx.table._Cell.merge
Basically, you define a rectangular region to merge by specifying two diagonal corner cells, so something like this:
table.cell(0, 0).merge(table.cell(1, 1))
would merge the top-left four cells, two in each of the first two rows.
Unfortunately, this feature has not yet been implemented in python-pptx
.
To accomplish this, you would need to extend python-pptx
with some sort of workaround function.
These issues from the GitHub project may provide some useful information if you want to pursue that:
https://github.com/scanny/python-pptx/issues?q=is%3Aissue+is%3Aopen+merge+label%3Atable
Upvotes: 6