代码片段来自xlwings
here的官方文档,它是我问题的设置。在
import xlwings as xw
sht = xw.Book().sheets[0]
sht.range('A1').value = [['Foo1', 'Foo2'], [1, 2]]
chart = sht.charts.add()
chart.set_source_data(sht.range('A1').expand())
chart.chart_type = 'line'
chart.name
运行print(chart.api)
输出下面的元组。在
如果我想使用api属性来执行一些基本的图表操作,如删除图例和添加标题,则只有在对chart.api[1]
执行此操作时才有效。例如,下面的代码可以正常工作。它删除图表图例并添加标题。在
chart.api[1].HasLegend = 0
chart.api[1].SetElement(2)
chart.api[1].ChartTitle.Text = 'A title'
但是,我对chart.api[0]
所做的任何操作都会产生错误(例如,print(chart.api[0].HasLegend)
会产生错误)。我不明白这是什么东西,也不知道它有多有用。我在官方文件中找不到任何与此相关的东西。在
最后我的问题是:上面索引0处的对象是什么?请帮我摸摸是什么。在
还有另一篇文章是关于索引0处对象的问题。在
set chart name in Xlwings
相关问题 更多 >
编程相关推荐