2010-06-05 6 views
3

xlwt를 사용하여 스크립트를 능가하는 MYSQL을 완료하고 쉽게 읽을 수 있도록 모든 두 번째 행을 색칠해야합니다. 이 색상은 괜찮 혼자Python - excel - xlwt : 두 번째 행마다 색을 지정합니다.

row = easyxf('pattern: pattern solid, fore_colour blue') 

for i in range(0,10,2): 

ws0.row(i).set_style(row) 

,하지만 내가 쓸 때 때 내 데이터 행을 다시 흰색과 같습니다

나는이 시도했다./

안부 : 나는 코딩 손실 해요 '사촌

몇 가지 좀 예를 보여 주시겠습니까.

답변

4

나는 write() 방법을 사용하여 행에만 색상을 적용했습니다.
이 기능이 작동합니까? (this excellent example에서 적응) :

mystyle = easyxf('pattern: pattern solid, fore_colour blue') 

for row in data: 
    rowx += 1 
    for colx, value in enumerate(row): 
     if rowx % 2 == 0: 
      # apply style for even-numbered rows 
      ws0.write(rowx, colx, value, mystyle) 
     else: 
      # no style for odd-numbered rows 
      ws0.write(rowx, colx, value) 
관련 문제