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.
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.