473,473 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

PyExcelerator: how to set colours?

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.

Dec 22 '06 #1
1 4427

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

Dec 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Marco Aschwanden | last post by:
Hi, Yesterday I placed a bug report on PyExcelerators-Sourceforge-page... but I am not so sure anymore, whether this is really a bug - I could imagine that I missed something, but I don't see...
3
by: tkpmep | last post by:
I downloaded PyExcelerator.zip as I need to write some data into Excel files, and tried unsuccessfully to install it. I unzipped the files into C:/Python24/Lib/site-packages/PyExcelerator, and in a...
2
by: tkpmep | last post by:
I have just installed PyExcelerator, and now want to use it to read Excel spreadsheets with a variable number of rows and columns and with multiple sheets. Unfortunately, no documentation seems to...
0
by: Jens Kabella | last post by:
Hi, i have a question with the pyexcelerator Modul. I´m using the Version 0.6.3a. Now I want to know how I can change the Colour Palette of Excel. I want to have my own colours for...
4
by: Marco Aschwanden | last post by:
Hi I would like to 1. import an existing Excel-sheet (a template) 2. and add some data to it 3. and save it under a different name afterwards. To me it seems, that pyExcelerator does not...
5
by: susan | last post by:
Hi, I'm new of Python, and this problem stucked me whole day but can't be solved. I use python 2.4.3, which is download from cygwin packages. Then I downloaded pyexcelerator-0.5.3a, unzip it, ...
3
by: tkpmep | last post by:
My program creates three lists: the first has dates expressed as strings, the second has floats that are strictly positive, and the third has floats that are strictly negative. I have no trouble...
1
by: aneesh.goel.rbtx | last post by:
I'm using pyExcelerator to take a folder of CSV files and create Excel workbooks for all of them, then generate an Excel workbook with the data from all of them. Everything up until here works...
1
by: patrick.waldo | last post by:
Hi all, I was just curious if there was a built-in or a more efficient way to do take multiple rows of information and write them into excel using pyExcelerator. This is how I resolved the...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.