from  docx import  Document
from  docx.oxml.ns  import  qn  #字体样式

w=Document()
table=w.add_table(3,3,style='Medium Grid 1 Accent 1')
table_head=table.rows[0].cells
table_head[0].text='名字'
table_head[1].text='性別'
table_head[2].text='年纪'

#将表格中全部的单元格改动字体样式

for  row in table.rows:
    for  cell in row.cells:
        for paragraph in cell.paragraphs:
            for run in paragraph.runs:
                run.font.name='Arial'   #英文字设定
                run._element.rPr.rFonts.set(qn('w:eastAsia'),'微软雅黑')
w.save(r'D:\word训练\给表格设定款式及改动字体样式.docx')

 

本文版权归趣KUAI排www.SEOguruBlog.com 所有,如有转发请注明来出,竞价开户托管,seo优化请联系QQ→61910465