saving a excel sheet as a csv file

Joost van Rooij j.vanrooij_at_e-quest.nl
Wed Jun 11 09:03:26 CEST 2003


>
> you might also want to rather use the form, but its been a while :-)
>
> wbk = xl.Workbooks.Open(source)
> wks = wbk.Worksheets(sheet)
>

Yep, you're right! thanks a lot!

from win32com.client import Dispatch

def xl2csv(source, destination, sheet):
    xl = Dispatch("Excel.Application")
    wbk = xl.Workbooks.Open(source)
    wks = wbk.Worksheets(sheet)
    wks.SaveAs(destination,FileFormat= "6")
    xl.Workbooks(1).Close(0)
    return

xl2csv("d:\\input.xls", "d:\\file2.csv", "Sheet2")






More information about the Python-list mailing list