main
黄海 9 months ago
parent b2810a91f9
commit c2f2d4975a

@ -4,7 +4,8 @@ import win32com
from win32com.client import Dispatch
docApp = win32com.client.Dispatch('Word.Application')
docApp.Visible = True
# 是不是打Word显示
docApp.Visible = False
docApp.DisplayAlerts = 0
doc = docApp.Documents.Open('c:/1.docx')
'''
@ -31,12 +32,13 @@ for inline_shape in doc.InlineShapes:
row_size = sheet.UsedRange.rows.Count
# 列数
col_size = sheet.UsedRange.columns.Count
print("行数=" + str(row_size) + ",列数=" + str(col_size))
# print("行数=" + str(row_size) + ",列数=" + str(col_size))
# 遍历获取表格中的数据
for i in range(1, row_size + 1):
for j in range(1, col_size + 1):
print(sheet.Cells(i, j).Value,end=" ")
print("")
print("")
idx = idx + 1
# 这里可以对图表进行操作,比如获取图表的类型、数据等

Loading…
Cancel
Save