CenterForOpenScience / pydocx

An extendable docx file format parser and converter
Other
183 stars 55 forks source link

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? #262

Open YuriiHamii opened 1 year ago

YuriiHamii commented 1 year ago

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")