pyExcelerator - Can I read and modify an existing Excel-WorkBook?

S

Stephen Brown

Yes indeed, pyExcelerator does support reading data from excel
spreadsheets. An example of how to do this is included in the file
xls2csv-gerry.py under the directory ... pyExcelerator/examples/tools
Syntax is pretty straight forward. extract_all = parse_xls(filename, CP
= None) where CP is the encoding format used within tht file. Uses
same codes that xlrd uses, ie 'cp437' = US English.

All you need is the "parse_xls" command and simply let it iterate
through your spreadsheet file.
EXAMPLE:

fname = "D:\\Directory\\myfile.xls" # an example filename
for sheet_name, values in parse_xls(fname ): # parse_xls(arg) --
default encoding
print " name of sheet is = ", sheet_name,

Alternatively you can extract everything in one go...

extract_all = parse_xls(fname)
 
J

John Machin

Yes indeed, pyExcelerator does support reading data from excel
spreadsheets.

I presume this is an orphaned and belated reply to the 3-message
thread in July 2006 with the same subject.
An example of how to do this is included in the file
xls2csv-gerry.py under the directory ... pyExcelerator/examples/tools
Syntax is pretty straight forward. extract_all = parse_xls(filename, CP
= None) where CP is the encoding format used within tht file.

The OP was aware of pyExcelerator's parse_xls, but required formatting
information:
"""
To me it seems, that pyExcelerator does not support the reading for
modification of an Excel-sheet. It allows only the "parse_xls" but I
would like to keep the "formatting" in the template.
"""
Uses
same codes that xlrd uses, ie 'cp437' = US English.

An interesting way of describing it. It is *not* restricted to being
a "codepage". The arg can be any Python-supported encoding that can be
passed to str.decode to convert internal 8-bit strings to unicode.
All you need is the "parse_xls" command and simply let it iterate
through your spreadsheet file.
[snip]

Current situation:

I am (sporadically) maintaining xlwt, a fork of pyExcelerator which
among other things fixes bugs and enables use with Python 2.3. It is
available from https://secure.simplistix.co.uk/svn/xlwt/trunk

xlwt.parse_xls is the same as pyExcelerator.parse_xls and thus has the
same deficiencies e.g. it reports a date as a floating-point number of
days since some more-or-less-fixed epoch and provides no indication
that the item should be interpreted as a date. It will not be
maintained, and is severely deprecated -- use xlrd instead.

HTH,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top