python30 excel修改模块xlutils
xlrd只读,xlwt只写,xlutils模块则将读写功能结合起来。https://pypi.org/project/xlutils/
修改excel通过xlutils的copy函数将<class 'xlrd.book.Book'>对象转变成<class 'xlwt.Workbook.Workbook'>对象。
简单应用
import xlrd from xlutils.copy import copy readbook = xlrd.open_workbook('test.xls') # 读取excel print(type(readbook)) writebook = copy(readbook) # 转变类型 print(type(writebook)) writesheet = writebook.get_sheet(0) writesheet.write(0,0,'change content')#修改内容 writebook.save('test.xls') #保存
copy前后的类型:
the end!
当情绪低落,烦躁的时候,学技术并整理成博客能忘却所有烦恼。技术改变心境。