Charts#

class Charts(impl)#

指定工作表中所有图表对象( chart )的集合:

>>> import xlwings as xw
>>> xw.books['Book1'].sheets[0].charts
Charts([<Chart 'Chart 1' in <Sheet [Book1]Sheet1>>,
        <Chart 'Chart 1' in <Sheet [Book1]Sheet1>>])

在 0.9.0 版本加入.

add(left=0, top=0, width=355, height=211)#

在指定的工作表中创建一个新的图表。

Arguments#

leftfloat, default 0

左边起点,单位是 point

topfloat, default 0

上边的起点,单位是 point

widthfloat, default 355

宽带,单位是 point

heightfloat, default 211

高度,单位是 point

返回#

Chart

示例#

>>> 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
'Chart1'
property api#

返回正在使用的引擎的原生对象( pywin32appscript 对象)。

property count#

返回集合中的对象数。