저는 파이썬 3.6.3을 사용하여 openpyxl (2.4.9)로 일부 엑셀 시트를 작성하고 있습니다. 차트 데이터에서 데이터 레이블을 가져 오는 것은 명확하지 않지만, 데이터 레이블을 형식화하려고하면 상황이 잘못 될 수 있습니다. 내가 할 수 있기를 원하는 것은 자신의 위치를 바꾸고 회전을 바꾸는 것입니다. 누구든지 어떤 아이디어? 파이썬에 조금 신선한 것이므로 어떤 조언도 훌륭합니다.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')