我正在尝试在xlwings-python中进行Charts API实现,用于基本图表操作,例如添加轴标题,更改线条颜色,绘制标记大小等。
我收到一个错误:
名称'xlCategory'未定义
实施的代码是
import xlwings as xw
wb = xw.Book(r'Tau.xlsm')
sht = wb.sheets.add(name ='Plot')
tau_plot = sht.charts.add()
tau_plot.chart_type='xy_scatter'
tau_plot.set_source_data(sht.range('E1:F135'))
tau_plot.api[1].Axes(xlCategory).HasTitle = True
你能帮我解决这个错误吗?
xlCategory
在XlAxisType下定义,xlCategory
是一个定义了许多常量值的枚举。如果您没有引用Excel类型库/对象模型,则1
对Python / xlwings没有任何意义。使用其基础值(xlCategory
),或定义您自己的副本,以便标识符1
与值>>> from xlwings.constants import AxisType
>>> AxisType.xlCategory
相关联。
您可以使用Excel的常量,如下所示:
qazxswpoi