openpyxl-是否可以从图表中删除边框? [英] openpyxl - Ability to remove border from charts?
问题描述
使用openpyxl,插入到我的工作表中的图表上面带有边框.是否可以通过styles.Style/styles.borders模块将图表的样式(饼图/条形图)设置为无边框,或者至少使用细白边框以使其能够无边界打印?
Using openpyxl, the charts inserted into my worksheet have a border on them. Is there any way to set the style of the chart (pie/bar) to either via the styles.Style/styles.borders module to have no border, or at least a thin white border so that they would print borderless?
我在对象上看到的唯一选项是.style = <int>
,它似乎并没有真正影响最终图形的设计.
The only options I see on the object is .style = <int>
which doesn't seem to actually affect the design of the final graphic.
推荐答案
您可以设置聊天图形属性,代码为
You can set chat graphical_properties, the code is
chart.graphical_properties = GraphicalProperties(ln=LineProperties(noFill=True))
这会将线型应用于chartSpace.
在执行此操作之前,应修改openpyxl lib
的源代码,文件为
This will apply the line style to chartSpace.
Before you do this, you should modifiy the source code of openpyxl lib
, the file is
Python27\Lib\site-packages\openpyxl\chart\_chart.py
#cs = ChartSpace(chart=container)
cs = ChartSpace(chart=container, spPr=self.graphical_properties)
效果很好.
这篇关于openpyxl-是否可以从图表中删除边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!