On 16/10/2009 1:15 AM, tscharf wrote:
> I am somewhat new to xlwt, not completely new to python.
Hi Tony, and welcome to the group.
> I am working on a report program, and the end user would like me to
> add some formatting to it, particularly some cell boarders and
> background color changes.
> The background color changes are easy, and I can write them as I write
> to the cells. The bigger issue is the cell boarders, which are
> intended to create a box around several cells at once.
> Is there a way in xlwt to set a border around a range of cells to
> group them together, rather than having to do it cell by cell?
> Obviously, that can be done, but its going to be messy considering
> this particular report.
You will need to do this cell by cell. It will help if you set up a
style aka XF for each different type of cell BEFORE you write any cells,
instead of doing it on the fly as you are writing cells. You will need 9
XFs (4 sides, 4 corners, and the middle) -- more if you have any fancy
formatting. You may end up with e.g. 3 rows of XFs (header, data, and
trailer).
Can you share your user's fancification request? I've got a few vague
thoughts on how a general purpose table formatter might look, but it
needs some stories -- anyone else out there who has done
borders/colours/patterns/number-formats etc for tabular data, please
throw your thoughts/stories/polished_code into the arena.
Cheers,
John