[Tutor] Need sample code to read xlsx files

Alan Gauld alan.gauld at yahoo.co.uk
Thu Aug 10 20:15:13 EDT 2023


On 10/08/2023 18:01, Avijit Shukla wrote:
> Hi I need sample code to use xlsx files..

We need more details. For one thing there are two
popular modules for working with Excel, one for
reading and one for writing, so it depends on what
you want to do to even decide which module to use.

Another common option if possible is to export the data
from Excel as a CSV file and use the standard library
csv module. (Or you can use the standard library
tools to work with the xml data in the raw excel
file, but that's tricky...

Finally, if the Excel includes macros etc then you may
need to use pywin to access the COM interface directly
(assuming it's on Windows), or alternatively use ctypes
to drive the Windows libraries.

So many options (and these are only some of the
possibilities!) we can't start to quote code until we
know what the code needs to do!

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos





More information about the Tutor mailing list