Writing to ms excel

Benjamin Kaplan benjamin.kaplan at case.edu
Sun Aug 31 05:57:38 CEST 2008


On Sat, Aug 30, 2008 at 9:32 PM, Marin Brkic <mbrkic at invalid_mail.adress>wrote:

> 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.
>
>
You can register for google groups, subscribe to the group, and go to My
Account -> Manage Subscriptions and select "No Email" for the subscription
type. That way, you can do everything (post, read, etc.) from
groups.google.com and not have to worry about filling up your email inbox.

>
> Best regards
> Marin
>
> >
> >HTH,
> >
> >John
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080830/ea0c9164/attachment.html>


More information about the Python-list mailing list