我有以下代码:
table = document.add_table(rows=1, cols=8)
hdr_cells = table.rows[0].cells
hdr_cells[0].text = 'Name'
hdr_cells[1].text = 'Surname'
hdr_cells[2].text = 'Telephone'
(...)有没有可能让这个单元格加粗呢?大概是这样的:
hdr_cells[0].text = 'Name'
hdr_cells[1].text = 'Surname'
hdr_cells[2].text = 'Telephone'
hdr_cells[0].text.bold = True
hdr_cells[1].text.bold = True
hdr_cells[2].text.bold = True发布于 2014-05-19 03:10:58
在这种特殊情况下,这应该会起到作用:
hdr_cells[0].paragraphs[0].add_run('Name').bold = True或者,更多的循序渐进:
col_names = ('Name', 'Surname', 'Telephone')
table = document.add_table(rows=1, cols=len(col_names))
hdr_cells = table.rows[0].cells
for idx, name in enumerate(col_names):
paragraph = hdr_cells[idx].paragraphs[0]
run = paragraph.add_run(name)
run.bold = Truehttps://stackoverflow.com/questions/23725352
复制相似问题