用Python对Excel获取sheet、增加sheet、写入单元格数据

import xlrd
import xlwt
from xlutils.copy import copy
wb = xlrd.open_workbook(r'C:\Users\刘世达\Desktop\零基础python处理excel表格基础办公自动化实战源码实例视频教程\01 Python处理Excel基础(python语言基础及excel基础操作)\配套资料及源文件\2章 用Python Excel读写数据-01\2章 用Python Excel读写数据\2.9 修改工作簿、工作表、单元格\招生表.xls')
nwb = copy(wb)
nws1 = nwb.add_sheet('上海分校')
nws3=nwb.get_sheet('上海分校')
nws3.write(5,7,'我来也')
nws3.write(0,0,'上海上海')
nwb.save(r'C:\Users\刘世达\Desktop\零基础python处理excel表格基础办公自动化实战源码实例视频教程\01 Python处理Excel基础(python语言基础及excel基础操作)\配套资料及源文件\2章 用Python Excel读写数据-01\2章 用Python Excel读写数据\2.9 修改工作簿、工作表、单元格\招生表3.xls')

posted on 2021-12-11 21:35  上山打老虎下山采蘑菇  阅读(1638)  评论(0编辑  收藏  举报

导航