tags:

views:

163

answers:

2

Hi,

i just finish some MYSQL to excel script with xlwt and I need to colour every second row for easy reading.

I have tried this:

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

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

ws0.row(i).set_style(row)

Alone this colouring is fine, but when when I write my data rows are again white.

Can some please show me some example 'cuz I m lost in coding :/

Best Regards.

+2  A: 

I've only ever applied color to rows using the write() method.
Does something like this work for you? (adapted from 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)
Adam Bernier
A: 

See the answer to your identical question in the python-excel google-group.

John Machin
That helped :) ty
Whit3H0rse