from docx. enum. table import WD_TABLE_ALIGNMENT
from docx. shared import Cm
from static. mysql_conn import db
from docx import Document
from docx. oxml. ns import qn
doc = Document( )
style = doc. styles[ 'Normal' ]
style. font. name = '微软雅黑'
style. element. rPr. rFonts. set ( qn( 'w:eastAsia' ) , '微软雅黑' )
run = doc. add_heading( '' , level= 1 ) . add_run( title_message[ 0 ] [ 0 ] )
run. font. name = u'微软雅黑'
run. _element. rPr. rFonts. set ( qn( 'w:eastAsia' ) , u'微软雅黑' )
table = doc. add_table( rows= 4 , cols= 3 , style= "Table Grid" )
table. cell( 0 , 0 ) . paragraphs[ 0 ] . paragraph_format. alignment = WD_TABLE_ALIGNMENT. CENTER
table. cell( 1 , 1 ) . paragraphs[ 0 ] . paragraph_format. alignment = WD_TABLE_ALIGNMENT. CENTER
table. cell( 2 , 2 ) . paragraphs[ 0 ] . paragraph_format. alignment = WD_TABLE_ALIGNMENT. CENTER
table. alignment = WD_TABLE_ALIGNMENT. CENTER
table. cell( dex, 0 ) . width = Cm( 1 )