Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Script to convert from XLSX to XLS
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Eduardo Silva  
View profile  
 More options Jun 20, 1:53 am
From: "Eduardo Silva" <market...@expresssignproducts.com>
Date: Fri, 19 Jun 2009 09:53:55 -0600
Local: Sat, Jun 20 2009 1:53 am
Subject: RE: [pyxl] Re: Script to convert from XLSX to XLS
> -----Original Message-----
> From: python-excel@googlegroups.com [mailto:python-
> excel@googlegroups.com] On Behalf Of vasudevram
> Sent: Thursday, June 18, 2009 6:46 PM
> To: python-excel
> Subject: [pyxl] Re: Script to convert from XLSX to XLS

> On Jun 15, 9:29 pm, Michael <selmo2...@gmail.com> wrote:
> > Recently I needed to quickly convert XLSX workbooks to XLS workbooks
> > so I could then interact with them via xlrd.  Here it is, hopefully
> it
> > will be useful to someone.  :)  Note that pywin32 is required to
> > interact with Excel 2007, so unfortunately this script will work only
> > on Windows with Excel 2007 installed.

> > This script is to be executed in the directory of XLSX workbooks
> > pending conversion.

> > import glob
> > import os
> > import time
> > import win32com.client

> > xlsx_files = glob.glob('*.xlsx')

> > if len(xlsx_files) == 0:
> >     raise RuntimeError('No XLSX files to convert.')

> > xlApp = win32com.client.Dispatch('Excel.Application')

> > for file in xlsx_files:
> >     xlWb = xlApp.Workbooks.Open(os.path.join(os.getcwd(), file))
> >     xlWb.SaveAs(os.path.join(os.getcwd(), file.split('.xlsx')[0] +
> > '.xls'), FileFormat=1)

> > xlApp.Quit()

> > # Delete or comment out the following lines if you want to preserve
> > the
> > # original XLSX files.

> > time.sleep(2) # give Excel time to quit, otherwise files may be
> locked
> > for file in xlsx_files:
> >     os.unlink(file)

> Interesting approach.

> For a possibly limited but cross-platform way (i.e. don't need to be
> on Windows or use pywin32) to do the same conversion from .XLSX
> to .XLS files, it is also possible to use an XML parser, such as a SAX-
> capable parser (to read the content (*) of the .XLSX files, and then
> write the same content to .XLS files using, I guess, the Python xlwt
> library, which is mentioned in other messages in this group.). (I have
> not used xlwt (yet), which is why I said "I guess", though I have used
> its counterpart for reading, xlrd, in my xtopdf toolkit.)

[My comments] I recall once doing a batch conversion of xls to xlsx with a tool provided for free download on the Microsoft's site. I can't recall if they had one for the same: xlsx to xls.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google