标签:
#!/usr/bin/env pythonfrom Tkinter import Tkfrom time import sleepfrom tkMessageBox import showwarningimport win32com.client as win32warn = lambda app: showwarning(app, ‘Exit?‘)RANGE = range(3, 8)def excel():app = ‘Excel‘xl = win32.gencache.EnsureDispatch(‘%s.Application‘ % app)ss = xl.Workbooks.Add()sh = ss.ActiveSheetxl.Visible = Truesh.Cells(1,1).Value = ‘Python-to-%s Demo‘ % appfor i in RANGE:sh.Cells(i,1).Value = ‘Line %d‘ % ish.Cells(i+2,1).Value = "Th-th-th-that‘s all folks!"warn(app)ss.Close(False)xl.Application.Quit()if __name__==‘__main__‘:Tk().withdraw()excel()
标签:
原文地址:http://www.cnblogs.com/highroom/p/49976f965557d9b90403f9910ee97838.html