excel - 在python中从excel中提取图表
问题描述
我想使用python代码从excel文件中提取图表作为图像
from win32com.client import Dispatch
excel = Dispatch("Excel.Application")
workbook = excel.ActiveWorkbook
xlsWB = excel.Workbooks.Open(r'D:\\indexing\\test.xlsx')
xlsSheet = xlsWB.Sheets("sheet1")
mychart = excel.Charts(1)
mychart.Export(Filename=r'D:\\indexing\\test.xlsx.png')
这是错误 iam gettig
错误:
com_error Traceback (most recent call last)
<ipython-input-31-95633a655eb6> in <module>
9 xlsSheet = xlsWB.Sheets("sheet1")
10
---> 11 mychart = excel.Charts(1) #'1' is the index of the chart object in
12
13 mychart.Export(Filename=r'D:\\indexing\\test.xlsx.png')
~\Anaconda3\lib\site-packages\win32com\client\dynamic.py in __call__(self, *args)
195 if invkind is not None:
196 allArgs = (dispid,LCID,invkind,1) + args
--> 197 return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
198 raise TypeError("This dispatch object does not define a default method")
199
com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352565), None)
解决方案
推荐阅读
- web - 不输入 www 就无法访问我的网站
- flutter - 如何在 Flutter 中对齐 RichText 区域中的文本?
- django - 使 PermissionRequiredMixin 也检查对象级别的权限
- d3.js - 带有双 x 轴的 D3 条形图,用于月份和年份
- java - 如何对时间相关的方法进行单元测试?
- amazon-dynamodb - dynamoDB 仅当地图中有 N 或更少项目时有条件写入
- jquery - CSS 样式 margin-top 在 Chrome 上工作,但在 Safari 14 中不工作
- node.js - 如何检查nodejs POST请求数据是否可以从流中读取或从正文中接收?
- android - 活动转换期间的动画视图
- docker - 构建多架构 Docker 映像时强制架构