码迷,mamicode.com
首页 > 其他好文 > 详细

EXCEL 写入

时间:2015-02-06 18:18:18      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:

  1. #!/usr/bin/env python
  2. from Tkinter import Tk
  3. from time import sleep
  4. from tkMessageBox import showwarning
  5. import win32com.client as win32
  6. warn = lambda app: showwarning(app, ‘Exit?‘)
  7. RANGE = range(3, 8)
  8. def excel():
  9. app = ‘Excel‘
  10. xl = win32.gencache.EnsureDispatch(‘%s.Application‘ % app)
  11. ss = xl.Workbooks.Add()
  12. sh = ss.ActiveSheet
  13. xl.Visible = True
  14. sh.Cells(1,1).Value = ‘Python-to-%s Demo‘ % app
  15. for i in RANGE:
  16. sh.Cells(i,1).Value = ‘Line %d‘ % i
  17. sh.Cells(i+2,1).Value = "Th-th-th-that‘s all folks!"
  18. warn(app)
  19. ss.Close(False)
  20. xl.Application.Quit()
  21. if __name__==‘__main__‘:
  22. Tk().withdraw()
  23. excel()





EXCEL 写入

标签:

原文地址:http://www.cnblogs.com/highroom/p/49976f965557d9b90403f9910ee97838.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!