Charts¶
- class Charts(impl)¶
A collection of all
chartobjects on the specified sheet:>>> 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)¶
Creates a new chart on the specified sheet.
- 參數:
left (float) -- left position in points
top (float) -- top position in points
width (float) -- width in points
height (float) -- height in points
範例
>>> 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'