xlrd只读,xlwt只写,xlutils模块则将读写功能结合起来。https://pypi.org/project/xlutils/

python30 excel修改模块xlutils

 

修改excel通过xlutils的copy函数将<class 'xlrd.book.Book'>对象转变成<class 'xlwt.Workbook.Workbook'>对象。

python30 excel修改模块xlutils

 

 简单应用

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前后的类型:

 python30 excel修改模块xlutils

 

 

the end!

 

相关文章:

  • 2022-12-23
  • 2021-12-02
  • 2021-09-27
  • 2022-12-23
  • 2021-09-14
  • 2021-08-27
  • 2021-05-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2021-12-08
相关资源
相似解决方案