openpyxl - Ability to remove border from charts?

a 夏天 提交于 2019-12-04 05:11:03

问题


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?

The only options I see on the object is .style = <int> which doesn't seem to actually affect the design of the final graphic.


回答1:


You can set chat graphical_properties, the code is

chart.graphical_properties = GraphicalProperties(ln=LineProperties(noFill=True))

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)

It works well.




回答2:


This isn't easy but should be possible. You will need to work through the XML source of a suitably formatted sample chart and see which particular variables need setting or changing. openpyxl implements the complete chart API but this unfortunately very complicated.



来源:https://stackoverflow.com/questions/36988384/openpyxl-ability-to-remove-border-from-charts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!