Re: Writing to ms excel
- From: Leonhard Vogt <leonhard.vogt@xxxxxx>
- Date: Sat, 30 Aug 2008 21:56:00 +0200
Marin Brkic schrieb:
I'm trying to find a way to write data to excel cells (or to be more
specific to an .xls file), let's say for the sake of argument, data
readen from a file (although it will be calculated in the process).
I've been searching, but couldn't find any examples which allows that.
If you have Excel installed you can use COM to access Excel and to
"remote-control" it in order to save a .xls file.
I have no Windows nor Excel at the moment, so I can only write something
approximative. Searching for win32com will help.
win32com.Coinitialize(...)
excel = win32com.client.Dispatch("Excel.Application")
wbook = excel.NewDocument()
sheet = wbook.Worksheets("Sheet1")
***.Cells(1,1) = "Abc"
wbook.Saveas("filename")
excel.close() or destroy()
win32com.coUninitialize()
The objects available are very similar to the VBA objects, so recording
a macro and translating its VBA source to python should not be hard.
HTH
Leo
.
- References:
- Writing to ms excel
- From: Marin Brkic
- Writing to ms excel
- Prev by Date: Re: When to use try and except?
- Next by Date: Re: Counting Elements in an xml file
- Previous by thread: Re: Writing to ms excel
- Next by thread: Re: Writing to ms excel
- Index(es):