|
|
|
@ -7,12 +7,31 @@ docApp = win32com.client.Dispatch('Word.Application')
|
|
|
|
|
docApp.Visible = True
|
|
|
|
|
docApp.DisplayAlerts = 0
|
|
|
|
|
doc = docApp.Documents.Open('c:/1.docx')
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
1:柱形图(Column)
|
|
|
|
|
2:折线图(Line)
|
|
|
|
|
3:饼图(Pie)
|
|
|
|
|
51:堆叠柱形图(Stacked Column)
|
|
|
|
|
52:堆叠线图(Stacked Line)
|
|
|
|
|
53:堆叠区域图(Stacked Area)
|
|
|
|
|
55:雷达图(Radar)
|
|
|
|
|
65:树状图(Treemap)
|
|
|
|
|
73:旭日图(Sunburst)
|
|
|
|
|
77:水桶图(Funnel)
|
|
|
|
|
109:散点图(Scatter)
|
|
|
|
|
183:气泡图(Bubble)
|
|
|
|
|
'''
|
|
|
|
|
# 遍历文档中的所有内嵌形状
|
|
|
|
|
idx = 1
|
|
|
|
|
for inline_shape in doc.InlineShapes:
|
|
|
|
|
if inline_shape.Type == win32com.client.constants.wdInlineShapeChart: # 检查是否为内嵌图表
|
|
|
|
|
print("找到一个图表")
|
|
|
|
|
pic1 = doc.InlineShapes(idx)
|
|
|
|
|
print(pic1.Chart.ChartType)
|
|
|
|
|
# print(pic1.Chart.ChartData.Workbook.FullName)
|
|
|
|
|
print(pic1.Chart.ChartStyle)
|
|
|
|
|
print(pic1.Chart.ChartTitle.Text)
|
|
|
|
|
idx = idx + 1
|
|
|
|
|
# 这里可以对图表进行操作,比如获取图表的类型、数据等
|
|
|
|
|
doc.Close()
|
|
|
|
|
docApp.Quit()
|
|
|
|
|
|
|
|
|
|