删除表格的行或者列

99封情书 提交于 2020-08-13 08:53:59
from  docx  import  Document
w=Document(r'F:\word练习\表格.docx')
table_1=w.tables[0]

#删除行
print(len(table_1.rows))
row2=table_1.rows[1]
row2._element.getparent().remove(row2._element)
print(len(table_1.rows))

#删除列
col=table_1.table.columns[1]
for  cell in  col.cells:
    cell._element.getparent().remove(cell._element)
w.save(r'F:\word练习\删除表格的行或者列.docx')

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!