Writing to ms excel

Marin Brkic mbrkic at invalid_mail.adress
Sat Aug 30 21:32:37 EDT 2008


On Sat, 30 Aug 2008 17:18:19 -0700 (PDT), John Machin
<sjmachin at lexicon.net> wrote:


Hello John (and everyone else), thanks for answering.

>It helps in situations like this to mention details of your
>environment
>(1) what version of what operating system (Linux, OS X, Windows, etc)
>(2) what version of Python
>as the available solutions are often dependent on the answers.

Yes, of course. I sometimes forget the most essential of things.
- winxp, sp2
- python 2.5.2

>
>For Python version 2.[345] on any platform, you can use xlwt, which is
>as simple as this for writing a 1-worksheet Excel 97-to-2003 XLS file
>(without any formatting):

Actually, that might work. What I was needing (aiming for) was a way
to write to excel 2003 files. Formatting is not necessary, since what
I'm trying to write is some tabular data; results from fortran-python
simulation (I can explain, but the details seem irrelevant for this
case).
I'm trying to avoid the text file - import to excel - mechanism, since
there is quite a lot of files written.
>
>def write_xls(file_name, sheet_name, data):
>    import xlwt
>    book = xlwt.Workbook()
>    sheet = book.add_sheet(sheet_name)
>    rowx = 0
>    for row in data:
>        rowx += 1
>        for colx, value in enumerate(row):
>            sheet.write(rowx, colx, value)
>    book.save(file_name)
># data can be any of the following Python types: int, long, float,
>decimal.Decimal, datetime.date, datetime.datetime, bool, str, and
>unicode.
>
>xlwt is available from https://secure.simplistix.co.uk/svn/xlwt/trunk
>
>I suggest that you join the python-excel group (http://
>groups.google.com.au/group/python-excel?hl=en) or at least read some
>of the questions and responses.

Please, one more question. As you have noticed, I posted my message to
comp.lang.python, using a newsreader. Is there a way to access google
groups through a similiar interface program as a newsreader. Never
used them before, and getting a lot of messages to my email every day
does not sound very appealing to me.

Best regards
Marin

>
>HTH,
>
>John



More information about the Python-list mailing list