我尝试用xlwings-python实现一个图表API,用于基本的图表操作,如添加轴标题、更改线条颜色、绘图标记大小等
我得到一个错误:
name 'xlCategory' is not defined
实现的代码是
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下,该枚举定义了许多常量值。如果您没有引用Excel类型库/对象模型,xlCategory
对Python/xlwings没有任何意义。使用它的基础值(1
),或者定义自己的副本,以便标识符xlCategory
与值1
相关联。在您可以使用Excel的常量,如下所示:
相关问题 更多 >
编程相关推荐