|
|
|
@ -25,14 +25,14 @@ doc = docApp.Documents.Open('c:/1.docx')
|
|
|
|
|
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)
|
|
|
|
|
sheet = pic1.Chart.ChartData.Workbook.Worksheets("Sheet1")
|
|
|
|
|
shape = doc.InlineShapes(idx)
|
|
|
|
|
sheet = shape.Chart.ChartData.Workbook.Worksheets("Sheet1")
|
|
|
|
|
print(sheet.Range("A2").Text)
|
|
|
|
|
# 行数
|
|
|
|
|
row_size = sheet.UsedRange.rows.Count
|
|
|
|
|
# 列数
|
|
|
|
|
col_size = sheet.UsedRange.columns.Count
|
|
|
|
|
print("行数="+str(row_size)+",列数=" + str(col_size))
|
|
|
|
|
idx = idx + 1
|
|
|
|
|
# 这里可以对图表进行操作,比如获取图表的类型、数据等
|
|
|
|
|
doc.Close()
|
|
|
|
|