Chart¶
- class Chart(name_or_index=None, impl=None)¶
chart对象是
charts
集合中的一员:>>> import xlwings as xw >>> sht = xw.books['Book1'].sheets[0] >>> sht.charts[0] # or sht.charts['ChartName'] <Chart 'Chart 1' in <Sheet [Book1]Sheet1>>
- property api¶
返回正在使用的引擎的原生对象(
pywin32
或appscript
对象)。Added in version 0.9.0.
- property chart_type¶
Returns and sets the chart type of the chart. The following chart types are available:
3d_area
,3d_area_stacked
,3d_area_stacked_100
,3d_bar_clustered
,3d_bar_stacked
,3d_bar_stacked_100
,3d_column
,3d_column_clustered
,3d_column_stacked
,3d_column_stacked_100
,3d_line
,3d_pie
,3d_pie_exploded
,area
,area_stacked
,area_stacked_100
,bar_clustered
,bar_of_pie
,bar_stacked
,bar_stacked_100
,bubble
,bubble_3d_effect
,column_clustered
,column_stacked
,column_stacked_100
,combination
,cone_bar_clustered
,cone_bar_stacked
,cone_bar_stacked_100
,cone_col
,cone_col_clustered
,cone_col_stacked
,cone_col_stacked_100
,cylinder_bar_clustered
,cylinder_bar_stacked
,cylinder_bar_stacked_100
,cylinder_col
,cylinder_col_clustered
,cylinder_col_stacked
,cylinder_col_stacked_100
,doughnut
,doughnut_exploded
,line
,line_markers
,line_markers_stacked
,line_markers_stacked_100
,line_stacked
,line_stacked_100
,pie
,pie_exploded
,pie_of_pie
,pyramid_bar_clustered
,pyramid_bar_stacked
,pyramid_bar_stacked_100
,pyramid_col
,pyramid_col_clustered
,pyramid_col_stacked
,pyramid_col_stacked_100
,radar
,radar_filled
,radar_markers
,stock_hlc
,stock_ohlc
,stock_vhlc
,stock_vohlc
,surface
,surface_top_view
,surface_top_view_wireframe
,surface_wireframe
,xy_scatter
,xy_scatter_lines
,xy_scatter_lines_no_markers
,xy_scatter_smooth
,xy_scatter_smooth_no_markers
Added in version 0.1.1.
- delete()¶
删除图表。
- property height¶
返回图表的高度,单位是
point
。
- property left¶
返回或者设置图表的水平位置,单位是
point
。
- property name¶
返回图表的名字。
- property parent¶
返回图表所属的对象。
Added in version 0.9.0.
- set_source_data(source)¶
设置图表的数据源区域。
Arguments¶
- sourceRange
区域对象,例如
xw.books['Book1'].sheets[0].range('A1')
- to_pdf(path=None, show=None, quality='standard')¶
Exports the chart as PDF.
参数¶
- pathstr or path-like, default None
Path where you want to store the pdf. Defaults to the name of the chart in the same directory as the Excel file if the Excel file is stored and to the current working directory otherwise.
- showbool类型, 缺省值为False
Once created, open the PDF file with the default application.
- qualitystr, default
'standard'
Quality of the PDF file. Can either be
'standard'
or'minimum'
.
Added in version 0.26.2.
- to_png(path=None)¶
Exports the chart as PNG picture.
参数¶
- pathstr or path-like, default None
Path where you want to store the picture. Defaults to the name of the chart in the same directory as the Excel file if the Excel file is stored and to the current working directory otherwise.
Added in version 0.24.8.
- property top¶
返回或者设置图表的垂直位置,单位是
point
。
- property width¶
返回图表的宽度,单位是
point
。