Xlwt from trunk, revision 3471
What can I do? I set the ws.col(i).width but it doesn't work, all
columns have the same width.
This is the content of the file:
from xlwt import *
w = Workbook()
ws = w.add_sheet('Hey, Dude')
for i in range(6, 80):
fnt = Font()
fnt.height = i*20
style = XFStyle()
style.font = fnt
ws.write(1, i, 'Test')
ws.col(i).width = 0x0d00 + i
w.save('col_width.xls')
Thanks
Alessandro
Hi Alessandro,
> example "col_width.py" doesn't work for me (linux debian, file "xls"
> opened with openoffice).
>
> Xlwt from trunk, revision 3471
>
> What can I do? I set the ws.col(i).width but it doesn't work, all
> columns have the same width.
It does work. Unfortunately the use of a tiny increment in the example
means that the change in column width is imperceptible to the naked eye.
OOo calc says that column G is 2.55 cm wide and column CB is 2.58 cm wide.
Thanks for reporting the problem.
Here's my suggested replacement:
8<---
#!/usr/bin/env python
import xlwt
wb = xlwt.Workbook()
ws = wb.add_sheet('ColWidth')
for colx in range(0, 5):
width = 1600 + colx * 500
# Units: 1/256 of the width of the zero character
# in the default font (first FONT record in the file).
ws.write(0, colx, width)
ws.col(colx).width = width
wb.save('col_width.xls')
8<---
Cheers,
John
Thanks for your answer! It does works
Before your answer I have tested the script with very little
increments.. but I saw nothing :-)
Alessandro