scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.35k stars 510 forks source link

Can we delete row from existing table from pptx developed by Python-Pptx. #791

Open VaishnaviDaware opened 2 years ago

VaishnaviDaware commented 2 years ago

Can we delete row from existing table from pptx developed by Python-Pptx.

Screenshot 2022-02-11 150725

I want to delete last 7th row from table. Is there anyway to do it?

And if we have use below function could you please provide any example of code for the same.

def remove_row(table: Table, row_to_delete: _Row) -> None: table._tbl.remove(row_to_delete._tr)

OR

def remove_row(table, row): tbl = table._tbl tr = row._tr tbl.remove(tr)

row = table.rows[n] remove_row(table, row)

Thank you

Originally posted by @VaishnaviDaware in https://github.com/scanny/python-pptx/issues/192#issuecomment-1036029544