当前位置: 移动技术网 > IT编程>脚本编程>Python > Python读写Excel

Python读写Excel

2018年09月28日  | 移动技术网IT编程  | 我要评论

梦碎昆仑玉,木吉他卡农吉他谱,贵烟价格表图

 读excel

1 #打开excek,xlsfile为excel路径+文件名
2 boorread  = xlrd.open_workbook(xlsfile)
3 #读取sheet,sheet_name为excel中sheet的名称
4 sheetread = boorread.sheet_by_name(sheet_name) 
5 #读取单元格内容
6 data = sheetread.cell_value(row, col)

 写excel

1 #创建文件对象
2 wrbook = xlwt.workbook(encoding='utf-8', style_compression=0)
3 #增加sheet
4 wrsheet = wrbook.add_sheet(sheet_name, cell_overwrite_ok=true)
5 #向单元格写数据,
6 wrsheet.write(row,col,data)
7 #保存文件
8 wrbook.save(xlsname)

修改已经存在的excel文件

1 book = xlrd.open_workbook(xlsfile,formatting_info=true)
2 book_wr = copy(book)
3 sheet_wr = bookwr.get_sheet(sheet_name)
4 sheet_wr.write(row,clo,data)
5 book_wr.save(file_name)

 详细可参看:https://blog.csdn.net/u013045749/article/details/49910695

 

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网