- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在研究使用 Python 来自动执行一些 Excel 数据分析。我掌握了大部分基础知识,但似乎找不到任何方法来成功调用 SetSourceData
或 SeriesCollection
。我读过 this post (以及所有其他人)并发现它充满希望,但它似乎与我的经验不符。我在 Windows 机器上使用 Python 2.7.3,32 位。
有没有人成功使用过SetSourceData
或SeriesCollection
?
这是我使用的代码和错误的简化版本:
chart = chartSheet.ChartObjects(1)
chart.SetSourceData(chartSheet.Range("A1:B2"),PlotBy=2)
我指定 PlotBy
因为 this , 但我怀疑这是否重要
错误:
raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr))
AttributeError: '<win32com.gen_py.Microsoft Excel 14.0 Object Library.ChartObject instance at 0x68557120>' object has no attribute 'SetSourceData'
唉。我应该看看 IronPython 吗? (我发现了 MSDN 文档中指定的其他一些内容,但在 Python 中似乎不起作用...但现在不记得了。)
最佳答案
这一行
chart = chartSheet.ChartObjects(1)
实际上并不返回一个Chart
对象(quote)
This method is not equivalent to the Charts property. This method returns embedded charts; the Charts property returns chart sheets. Use the Chart property to return the Chart object for an embedded chart.
我没试过这个,但听起来好像你需要引用 chart
属性,可能是这样的:
chartObject = chartSheet.ChartObjects(1)
chart = chartObject.chart
关于Python 和 win32com.client 似乎缺少方法,特别是 SetSourceData,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16315873/
我已经为此投入了相当多的时间,但似乎找不到解决方案。 我正在使用工作表选择更改事件,该事件允许人们修改图表元素,而无需打开图表格式选项。当我尝试使用时出现问题 .Chart.SetSourceData
我的公司使用 Excel 2003 创建的应用程序有问题。应用程序从源检索数据,并使用 VBA 例程中的 SetSourceData 更新图表,传递包含写入相关数据的单元格的范围。 该应用程序在 Of
我有一个 Excel VBA 应用程序,该应用程序在 Excel 2003 中运行良好,但在 Excel 2010 中失败。 相关代码为 Public Sub Create_Chart Dim
我正在研究使用 Python 来自动执行一些 Excel 数据分析。我掌握了大部分基础知识,但似乎找不到任何方法来成功调用 SetSourceData 或 SeriesCollection。我读过 t
我想在一个工作表中创建多个数据透视表,并从每个数据透视表创建一个图表。第一个数据透视表和第一个图表是正常创建的。创建第二个数据透视表后,我想添加第二个图表,其源来自第二个数据透视表,但这比 HRESU
我是一名优秀的程序员,十分优秀!