python-pptx icon indicating copy to clipboard operation
python-pptx copied to clipboard

Feature removal of "columns.add()" and "rows.add()" for tables?

Open JacobMSager opened this issue 1 year ago • 2 comments

Hello,

I've been using Python-PPTX 0.6.23 for a script that converts excel spreadsheets into PowerPoint tables, with a row and column count that varies depending on the input. Up until this point I've been creating a table object, and then adding rows and columns to the table using "table.columns.add()" or "table.rows.add()" procedurally as the script determines based on how many cell rows or cell columns are in the excel sheet. Unfortunately, that method is no longer viable as of Python-PPTX v1.0.0, for reasons I'm not clear on. Every time I run "table.columns.add()" or "table.rows.add()" I receive the error "'_ColumnCollection' object has no attribute 'add'" or "'_RowCollection' object has no attribute 'add'". This was never an issue in v0.6.23.

Of course, I COULD just run a check for how many columns and rows I need before I create the table and it would work fine, but I'm just confused as to why this feature was removed in the first place. What was the cause for this change? Was that feature erroneously removed? The feature still exists in Microsoft's PowerPoint API per: https://learn.microsoft.com/en-us/previous-versions/office/developer/office-2010/ff745415(v=office.14). Was the Python-PPTX syntax changed for this feature and I'm just not looking in the right place in the docs? Thank you in advance for your time.

JacobMSager avatar Oct 02 '24 23:10 JacobMSager

I feel your pain @JacobMSager. I'm sure I remember someone re-adding these functions in a pull request.

peterarich avatar May 06 '25 09:05 peterarich

https://github.com/scanny/python-pptx/pull/399

peterarich avatar May 06 '25 09:05 peterarich