|
|
|
@ -7,8 +7,11 @@ docApp = win32com.client.Dispatch('Word.Application')
|
|
|
|
|
# 是不是打Word显示
|
|
|
|
|
docApp.Visible = False
|
|
|
|
|
docApp.DisplayAlerts = 0
|
|
|
|
|
doc = docApp.Documents.Open('c:/1.docx')
|
|
|
|
|
# doc = docApp.Documents.Open('c:/1.docx')
|
|
|
|
|
doc=docApp.Documents.Open('c:/昭通市人口变化及其对教育的影响20240416.docx')
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
Type
|
|
|
|
|
1:柱形图(Column)
|
|
|
|
|
2:折线图(Line)
|
|
|
|
|
3:饼图(Pie)
|
|
|
|
@ -28,13 +31,12 @@ for inline_shape in doc.InlineShapes:
|
|
|
|
|
if inline_shape.Type == win32com.client.constants.wdInlineShapeChart: # 检查是否为内嵌图表
|
|
|
|
|
shape = doc.InlineShapes(idx)
|
|
|
|
|
# 获取图表的标题
|
|
|
|
|
print(shape.Chart.ChartTitle.Text)
|
|
|
|
|
# print(shape.Chart.ChartTitle.Text)
|
|
|
|
|
sheet = shape.Chart.ChartData.Workbook.Worksheets("Sheet1")
|
|
|
|
|
# 行数
|
|
|
|
|
row_size = sheet.UsedRange.rows.Count
|
|
|
|
|
# 列数
|
|
|
|
|
col_size = sheet.UsedRange.columns.Count
|
|
|
|
|
# print("行数=" + str(row_size) + ",列数=" + str(col_size))
|
|
|
|
|
# 遍历获取表格中的数据
|
|
|
|
|
for i in range(1, row_size + 1):
|
|
|
|
|
for j in range(1, col_size + 1):
|
|
|
|
|