SHARE
TWEET

Untitled

a guest Jun 26th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2.  
  3. from tkinter import Tk
  4. from time import sleep
  5. from tkinter.messagebox import showwarning
  6. import win32com.client as win32
  7.  
  8. warn = lambda app: showwarning(app, 'Exit?')
  9. RANGE = range(3, 8)
  10.  
  11.  
  12. def excel():
  13.     app = 'Excel'
  14.     xl = win32.gencache.EnsureDispatch('%s.Application' % app)
  15.     ss = xl.Workbooks.Add()
  16.     sh = ss.ActiveSheet
  17.     xl.Visible = True
  18.     sleep(1)
  19.  
  20.     sh.Cells(1, 1).Value = 'Python-to-%s Demo' % app
  21.     sleep(1)
  22.     for i in RANGE:
  23.         sh.Cells(i, 1).Value = 'Line %d' % i
  24.         sleep(1)
  25.     sh.Cells(i + 2, 1).Value = "Th-th-th-that's all wolks!"
  26.  
  27.     warn(app)
  28.     ss.Close(False)
  29.     xl.Application.Quit()
  30.  
  31.  
  32. if __name__ == '__main__':
  33.     Tk().withdraw()
  34.     excel()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top