print("从《Python 核心编程》学习Microsoft Office编程");Step1(Excel);
2016-10-09 15:33
309 查看
我从未见过如此简单的Excel控制程序
简述
你们可能见过我的另一篇关于Excel控制的文章: 《使用VC++6.0 MFC OLE操作Excel 进行简单的读写》 http://blog.csdn.net/llwodao/article/details/51568472 申请对象,载入资源,free对象,简直是一场灾难QAQ. 然后python来了,突然感觉写入就像是简单的赋值。
#EXCEL Control Demo from tkinter import Tk from time import sleep from tkinter.messagebox import showwarning import win32com.client as win32 warn = lambda app: showwarning(app , 'Exit?') RANGE = range(3 ,8); def excel(): app = 'Excel' x1 = win32.gencache.EnsureDispatch('%s.Application'%app) ss = x1.Workbooks.Add() sh = ss.ActiveSheet x1.Visible = True sleep(1) sh.Cells(1,1).Value = 'Python-to-%s Demo' %app sleep(1) for i in RANGE: sh.Cells(i,1).Value = 'Line %d' %i sleep(1) sh.Cells(i+2,1).Value = "It comes to the end!" warn(app) ss.Close(False) x1.Application.Quit() if __name__ =='__main__': Tk().withdraw() excel()
相关文章推荐
- python核心编程学习杂记1:print
- python核心编程学习(三)
- python核心编程学习杂记2:__name__指示模块应如何被加载
- python核心编程学习(第四章)
- Python学习日志20150717-Python核心编程基础教程之Python运算符、运算符优先级、表达式简介
- Python-核心编程-学习笔记
- python核心编程学习(四)
- Python核心编程--学习笔记--5--数字
- python核心编程学习(第二章)
- Python核心编程--学习笔记--7--字典和集合
- Python核心编程笔记---- print
- python核心编程学习(六)
- Python核心编程--学习笔记--3--Python基础
- 学习python核心编程-第三章-课后习题笔记
- python核心编程学习(第三章)
- python 核心编程学习笔记(第3章) 对应Let's-python视频第4集
- Python核心编程--学习笔记--2--Python起步(上)
- Python核心编程--学习笔记--2--Python起步(下)
- python核心编程学习
- Python核心编程--学习笔记--9--文件和输入输出