Good. You won't miss it. Flick it and get xlwt from
http://pypi.python.org/pypi/xlwt. Then
g/pyExcelerator/s//xlwt/
in your source code and you're off. Benefits: it's maintained, it's
fixed a bug or two, it's faster, it's being enhanced, and it's not
called eXceLWriTe so you don't need 3 attempts to get your import
statements spelled right :-)
> I am writing data in the excel
> workbook using following
>
> ws1 = w.add_sheet('CFG_Test_Case')
> UnicodeUtils.DEFAULT_ENCODING = 'CFG_Test_Case'
Given that in pyExcelerator IIRC UnicodeUtils.DEFAULT_ENCODING is
'cp1251', either (a) you have installed your own codec, called
'CFG_Test_Case' or (b) you are ever so slightly confused. What is the
purpose of that statement?
> ws1.write(0, 1, 'Test Case ID',style0)
> w.save('CFG_Test_Case.xls')
>
> when i opened the CFG_Test_Case.xls document the content in the 1
> row 1 Column displayed as "Test Case ID" but the format is displayed
> as " General" is there any way to make it "Text" while writing data
> using Pyexcelarator?
With pyExcelerator, you'd need to poke stuff into XFStyle objects, like
style0.num_format_str = "@"
xlwt will still accept that, but the better way is to use easyxf, as in
the example below. In this case it's more keystrokes, but you'll see
when you start specifying fonts and alignments and colours that "easyxf"
is not just a marketing name :-)
>>> import xlwt
>>> style0 = xlwt.easyxf(num_format_str="Text") # Wrong
>>> style1 = xlwt.easyxf(num_format_str="@") # Right
>>> b = xlwt.Workbook()
>>> s = b.add_sheet('x')
>>> s.write(0, 0, 'foo', style0)
>>> s.write(0, 1, 'foo', style1)
>>> s.write(1, 0, 123.4, style0)
>>> s.write(1, 1, 123.4, style1)
>>> b.save('Text_fmt.xls')
See the easyxf section in the xlwt docs, and look for easyxf in the
examples directory.
Cheers,
John
Glad to hear it. What was
UnicodeUtils.DEFAULT_ENCODING = 'CFG_Test_Case'
all about?
> just a question can we write an array data in excel file using xlwt?
Do you mean an array formula? If so, not at the moment. Search this
group for a thread on the topic around 6 or 7 Jan 2009. If not, please
explain what you mean. Consider starting a new topic.
Cheers,
John