Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98893 > unrolled thread

write data in Excel using python

Started bysyedmwaliullah@gmail.com
First post2015-11-16 09:14 -0800
Last post2015-11-16 17:43 -0800
Articles 4 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  write data in Excel using python syedmwaliullah@gmail.com - 2015-11-16 09:14 -0800
    Re: write data in Excel using python Michiel Overtoom <motoom@xs4all.nl> - 2015-11-16 19:20 +0100
    Re: write data in Excel using python Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-16 17:22 -0700
    Re: write data in Excel using python tdsperth@gmail.com - 2015-11-16 17:43 -0800

#98893 — write data in Excel using python

Fromsyedmwaliullah@gmail.com
Date2015-11-16 09:14 -0800
Subjectwrite data in Excel using python
Message-ID<3267f6a3-a047-4abf-80bf-8fdba3659223@googlegroups.com>
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()

[toc] | [next] | [standalone]


#98900

FromMichiel Overtoom <motoom@xs4all.nl>
Date2015-11-16 19:20 +0100
Message-ID<mailman.372.1447698129.16136.python-list@python.org>
In reply to#98893
Hi,

> On 16 Nov 2015, at 18:14, syedmwaliullah@gmail.com wrote:
> For some reason it doesn't save the file.

Did you get an error message?

> excel.activeWorkbook.SaveAs ("c:\TurnData.xlsx")

When you use backslashes in strings, don't forget to escape them:

> excel.activeWorkbook.SaveAs("c:\\TurnData.xlsx")

or use raw strings:

> excel.activeWorkbook.SaveAs(r"c:\TurnData.xlsx")

Greetings,

[toc] | [prev] | [next] | [standalone]


#98903

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-11-16 17:22 -0700
Message-ID<mailman.373.1447720302.16136.python-list@python.org>
In reply to#98893
On Mon, Nov 16, 2015 at 11:20 AM, Michiel Overtoom <motoom@xs4all.nl> wrote:
>
> Hi,
>
>> On 16 Nov 2015, at 18:14, syedmwaliullah@gmail.com wrote:
>> For some reason it doesn't save the file.
>
> Did you get an error message?
>
>> excel.activeWorkbook.SaveAs ("c:\TurnData.xlsx")
>
> When you use backslashes in strings, don't forget to escape them:
>
>> excel.activeWorkbook.SaveAs("c:\\TurnData.xlsx")
>
> or use raw strings:
>
>> excel.activeWorkbook.SaveAs(r"c:\TurnData.xlsx")

You can also just use a forward slash:

excel.activeWorkbook.SaveAs("c:/TurnData.xlsx")

Windows happily accepts this.

[toc] | [prev] | [next] | [standalone]


#98906

Fromtdsperth@gmail.com
Date2015-11-16 17:43 -0800
Message-ID<317940a3-ac2f-4d0a-8ed5-9395cca9835b@googlegroups.com>
In reply to#98893
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web