나는 탁월함을 위해 파이썬에서 엑셀로 작업 스크립트를 작성하려고합니다. 이미 열의 크기와 형식을 형식화해야했지만 열 중 하나에 조건부 색이 있어야합니다.
예/ 열 A에 백분율이 있습니다. 모든 셀 < 0 %의 경우 , 우리는 모든 셀 = 0 %를 빨간색으로 세포를 필요, 우리는 모든 셀 노란색으로 세포를 필요> 0 %, 우리가 녹색으로 세포를 필요파이썬에서 조건부 배경색 - 파이썬에서 새로움
그리고 그런 다음 각 열의 첫 번째 행은 파란색이어야합니다.
비슷한 스크립트를 발견했지만 조건부는 아닙니다.
나는
# Light red fill.
format1 = name.add_format({'bg_color': '#FFC7CE'})
# Light yellow fill.
format2 = name.add_format({'bg_color': '#FFEB9C'})
# Green fill.
format3 = name.add_format({'bg_color': '#C6EFCE'})
try:
sheet1.conditional_format('A:A', {'type': 'cell',
'criteria': '<',
'value': 0,
'format': format1})
sheet1.conditional_format('A:A', {'type': 'cell',
'criteria': '==',
'value': 0,
'format': format2})
sheet1.conditional_format('A:A', {'type': 'cell',
'criteria': '>',
'value': 0,
'format': format3})
except AttributeError:
sheet1.conditional_format = None
except TypeError:
type = None
의 몇 가지 변화를 시도했다하지만 색상
을 변경하지 않고, 나는
while 'BU:BU' != " " :
if 'BU:BU' < '0%':
sheet1.style = redFill
elif 'BU:BU' == '0%':
sheet1.style = yellowFill
elif 'BU:BU' > '0%':
sheet1.style = '#C6EFCE'
else:
pass
continue
의 몇 가지 변화를 시도했다하지만 그 유지 무한 루프에 빠지기.
감사합니다.