PyExcelerator: how to set colours?

Gerry gerard.blais at gmail.com
Fri Dec 22 10:30:32 EST 2006


I'd like some cell to be a Blue "ABCDE".

Here's come code thatv tries various values for pattern_for_colour and
font.colour_index, to no avail.

Can anyone suggest the right way to set colours?

Thanks!

Gerry

======================

from pyExcelerator import *

w       = Workbook()
ws      = w.add_sheet('alpha')

style   = XFStyle()
fore_colour = style.pattern.pattern_fore_colour
back_colour = style.pattern.pattern_back_colour

ws.write (1, 1, "fore_colour")
ws.write (1, 2, fore_colour)

ws.write (2, 1, "back_colour")
ws.write (2, 2, back_colour)

text    = "ABCDE"

row     = 5



for offset in range(-32,512):

    row += 1

    style.font.colour_index = fore_colour + offset

    ws.write(row,3, fore_colour + offset, style)

    ws.write(row,5,text,                                    style)

    style.pattern.pattern_fore_colour = fore_colour + offset

    ws.write(row,6,text,                                    style)

w.save('test.xls')

=====================

shows no colour variation for any of these values of offset.




More information about the Python-list mailing list