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.
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.
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