saving a excel sheet as a csv file
Graeme Matthew
gsmatthew at ozemail.com.au
Tue Jun 10 07:53:32 EDT 2003
what about ---> xl2csv("d:\\file.xls", "d:\\file.csv", Sheet)
you might also want to rather use the form, but its been a while :-)
wbk = xl.Workbooks.Open(source)
wks = wbk.Worksheets(sheet)
"Joost van Rooij" <j.vanrooij_at_e-quest.nl> wrote in message
news:3ee5b556$0$49116$e4fe514c at news.xs4all.nl...
> Hello,
>
> I would like to save an Excel file to a csv file, which works nicely using
> com, but I can't seem to find out how to be able to select a particular
> sheet.
>
> This code converts all right, but the selecting the right sheet won't
> work...
>
> from win32com.client import Dispatch
>
> def xl2csv(source, destination, sheet):
> xl = Dispatch("Excel.Application")
> xl.Workbooks.Open(source)
> xl.Sheets.Select(sheet)
> xl.ActiveWorkbook.SaveAs(destination,FileFormat= "6")
> xl.Workbooks(1).Close(0)
> return
>
> xl2csv("d:\\file.xls", "d:\\file.csv", "Sheet2")
>
> Any help would be very much appreciated....
>
> grtz Joost
>
>
More information about the Python-list
mailing list