Gerry wrote: > 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.
Is this what you were after? -------------------------------------------------------------- from pyExcelerator import * w = Workbook() ws = w.add_sheet('boo') 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 fnt = Font() fnt.colour_index = fore_colour + offset style.font = fnt ws.write(row, 3, offset, style) ws.write(row, 5, text, style) p = Pattern() p.pattern_fore_colour = fore_colour + offset p.pattern = style.pattern.SOLID_PATTERN style.pattern = p ws.write(row, 6, text, style) w.save('test.xls') -------------------------------------------------------------------------------- Waldemar -- http://mail.python.org/mailman/listinfo/python-list