首页 > 编程语言 > 详细

Python借鉴-python-操作excel

时间:2020-11-11 11:45:15      阅读:31      评论:0      收藏:0      [点我收藏+]

1)用管理员身份打开dos命令行----pip install openpyxl

2)用管理员身份运行 pycharm

复制代码

存到excel里面,python去操作excel文件

只支持这种后缀,xlsx ,openpyxl只支持这种格式

pip install openpyxl

from openpyxl import load_workbook

1:打开文件,加载用例薄

wb=load_workbook("D:\test.xlsx") #和file=open()差不多

2:定位表单

sheet = wb[‘test_sheet1‘]  #test_sheet1是sheet表的名字

3:定位单元格

res1 = sheet.cell(row=1, column=1).value
print(res1)
‘‘‘
print(sheet.max_column)
print(sheet.max_row)‘‘‘

res2 = sheet.cell(row=2, column=2).value
print(res2)
‘‘‘print(sheet.max_column)
print(sheet.max_row)‘‘‘

res3 = sheet.cell(row=3, column=3).value
print(res3)
‘‘‘print(sheet.max_column)
print(sheet.max_row)‘‘‘
复制代码
参考文档:https://www.cnblogs.com/wuzm/p/11977694.html 感谢博主

Python借鉴-python-操作excel

原文:https://www.cnblogs.com/6413dls/p/13957573.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!