pydocx icon indicating copy to clipboard operation
pydocx copied to clipboard

Hello, I followed the example from your documentation to hidden column and row in table - my docx file. How should one row or one column be hidden?

Open YuriiHamii opened this issue 2 years ago • 0 comments

from docx import Document

document = Document("to_hide.docx") Table = document.tables[0] par = Table.rows[0].cells[1].paragraphs[0]

hidden - only one cell

counter=0 for runs in par.runs: counter += 1 runs.font.hidden = True # True False print("Run", counter, " : ", runs.text)

hidden - column - 1

for col in Table.columns[1].cells: style = document.styles['Normal'] col.font = style.font col.font.hidden = True

hidden - row - 0

for cells in Table.rows[0].cells: style = document.styles['Normal'] cells.font = style.font cells.font.hidden = False

document.save("to_hide.docx")

YuriiHamii avatar Aug 18 '22 21:08 YuriiHamii