''导入com对象 '''
import time
import win32com.client as win32
word = win32.gencache.EnsureDispatch('Word.Application',1)
word.Visible = 1
''内容 '''
doc = word.Documents.Add()
doc.Top = 1
doc.Content.Text = "hello world"
doc.Content.Paragraphs.Add()
doc.Content.InsertAfter("hello2 ?")
doc.Content.InsertAfter("hello world 3")
''' 表的位置 '''
location = doc.Range()
location.Move() # place table at the end
''”
第一桌
'''
table = doc.Content.Tables.Add(location, 2, 4)
''”
第二桌
'''
table2 = doc.Content.Tables.Add(location, 2, 2)
table2.PreferredWidth = 40
table.ApplyStyleHeadingRows = 0
table.AutoFormat(16)
table.PreferredWidth = 400
doc.Content.InsertAfter("hello4 hello5")
目前没有回答
相关问题 更多 >
编程相关推荐