问题
I am creating a table using python 3.4 and I would like to make the header both bold and underline. The following code will make the header bold:
table = document.add_table(rows=1, cols=3)
hdr_cells = table.rows[0].cells
hdr_cells[0].paragraphs[0].add_run('Date Filmed:').bold = True
hdr_cells[2].paragraphs[0].add_run('Barcode Number:').bold = True
If I change the 3rd line to:
hdr_cells[0].paragraphs[0].add_run('Date Filmed:').underline = True
it will make the text underlined, but not bold. It there a way to make the text of the header both bold and underlined?
回答1:
You just need to add boolean run properties one at a time
run = hdr_cells[0].paragraphs[0].add_run('Date Filmed:')
run.bold = True
run.underline = True
来源:https://stackoverflow.com/questions/31797491/how-can-i-make-table-header-cells-both-bold-and-underline-in-python