write data in Excel using python

tdsperth at gmail.com tdsperth at gmail.com
Mon Nov 16 20:43:18 EST 2015


On Tuesday, November 17, 2015 at 1:14:56 AM UTC+8, SW wrote:
> hi, 
> I am trying to write Excel file suing output from another software where the output comes as myturnlist.Show()
> 
> The first part is for the output from the software which is saved in the clipboard. 
> 
> The big middle part works to open Excel and save the data into excel file called "TurnData.xlsx". 
> 
> For some reason it doesn't save the file. 
> 
> Any idea?
> 
> Thanks in advance.
> 
> 
> import VisumPy.excel
> 
> # Write to Excel
> 
> myturnlist.Show()
> turnData = myturnlist.SaveToClipboard(59,0)
> 
> excel = win32com.client.Dispatch("Excel.Application")
> wb = excel.Workbooks.Add()
> exce.Visible = True
> wb.WorkSheets[0].Paste()
> excel.activeWorkbook.SaveAs ("c:\TurnData.xlsx")
> 
> myturnlist.Close()

Take out exce.Visible = True ( which I believe is atypo)

Colin



More information about the Python-list mailing list