import win32com client book win32com client Dispatch Excel Application

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import win32com.client
book = win32com.client.Dispatch("Excel.Application")
book.Visible = 1
book.Workbooks.Add()
xlBook = book.Workbooks(1)
xlSheet = book.Sheets(1)
for i in xrange(len(book.Sheets)):
book.Sheets[i].Name = "Hello (%i)" % i
xlSheet.Cells(1,1).Value = "Python Rules!"