<div>Hello,</div>
<div> </div>
<div>I am trying to automate Excel and I cant seem to find out much relating to it's object model (in relation to Python)..seems as if its mostly covered by C and VB. Can anyone point me in the right direction? I am able to open excel, add information to cells, and then save and close the book opened. I was looking to get into formatting of cells, formulas, etc.
</div>
<div> </div>
<div>Below is the code i have now...any responces would help.</div>
<div> </div>
<div>
<p>import PAM<br>import time<br>from win32com.client import Dispatch #this is needed to open an Excel file<br>execfile('c:\\Python24\\scripts\\PAM.py')<br>f = open('c:\python24\scripts\urls.txt','r') #opens list of urls to be tested
<br>xlApp = Dispatch("Excel.Application")<br>xlApp.Visible = 0<br>xlApp.Workbooks.Add()<br>Row = 1</p>
<p>for x in f: #run this for every url in txt file.<br> ie = IE_Invoke(x)<br> starttime = time.clock() #get timestamp at IE startup<br> wait(ie) #wait for IE to completetly load page<br> stoptime = time.clock() #get timestamp at IE completion
<br> elapsed = stoptime-starttime #calculate the runtime<br> ie.QUIT()<br> xlApp.ActiveSheet.Cells(Row,1).Value = x <br> xlApp.ActiveWorkbook.ActiveSheet.Cells(Row,2).Value = elapsed<br> Row = Row+1</p>
<p>xlApp.ActiveWorkbook.ActiveSheet.SaveAs('c:\\test_results\dave.xls') #save results to excel book<br>xlApp.Quit() <br> </p></div>