私はPython 3.6.3を使って、openpyxl(2.4.9)でいくつかのExcelシートを作成しています。グラフ化されたデータのデータラベルを取得することは明らかではありませんでしたが、データラベルをフォーマットしようとすると状況が悪くなります。私ができることを望みたいのは、彼らのポジションを変えたり、自分のローテーションを変えたりすることです。誰にでもアイデアはありますか?私は少しPythonの新鮮ですので、任意のアドバイスが素晴らしいだろう。openpyxlでのチャートデータラベルの書式設定
from openpyxl.chart import LineChart, Reference, Series
from openpyxl.chart.label import DataLabelList
from openpyxl.chart.text import RichText
from openpyxl.drawing.text import RichTextProperties
#this is the only way I found to set text properties which didnt give an error
vertical = RichTextProperties(rot = 270)
labelvertical = RichText(bodyPr = vertical)
chart1 = LineChart()
# setup and append the first series
values = Reference(dprsheet, min_col=5, min_row=4, max_row=34)
series = Series(values, title="Series 1")
chart1.append(series)
# setup and append the second series
values = Reference(dprsheet, min_col=8, min_row=4, max_row=34)
series = Series(values, title="Series 2")
chart1.append(series)
dates = Reference(dprsheet, min_col=2, min_row=4, max_row=34)
chart1.set_categories(dates)
s1 = chart1.series[0]
s1.graphicalProperties.line.solidFill = 'FF0000'
s1.graphicalProperties.line.width = 25000
s1.dLbls = DataLabelList()
s1.dLbls.showVal = True
## s1.dLbls.dLblPos = 't'
## if ^this^ line isn't commented then ALL images in the sheet are removed by excel upon opening
## s1.dLbls.txPr = labelvertical
## if ^this^ line isn't commented then ALL images in the sheet are removed by excel upon opening
s2 = chart1.series[1]
s2.graphicalProperties.line.solidFill = '000000'
s2.graphicalProperties.line.width = 25000
essheet.add_chart(chart1, 'B35')