当前位置:网站首页>openpyxl表格读取实例
openpyxl表格读取实例
2022-06-27 09:15:00 【远吗我的香格里拉】
from openpyxl import load_workbook
# 从表格读取数据操作
def read_data_from_excel(excel_path,sheet_name):
wb = load_workbook(filename=excel_path,read_only=True)
# 读取指定页面
ws = wb[sheet_name]
#-----------<打印单个单元格(A4)的值>-------------------#
d=ws.cell(row=4,column=1)
print(d.value)
#-----------<打印单个单元格(A4)的值>-------------------#
#-----------<将某个区域的值存放到二维数组>-------------#
data_arr=[]
for row in ws.iter_rows(min_row=3,max_row=6,max_col=4):
tmp=[] #每行的值存放到数组中
for cell in row:
tmp.append(cell.value)
data_arr.append(tmp)
return data_arr
#-----------<将某个区域的值存放到二维数组>-------------#
#调用参数
excel_path="./test.xlsx"
#调用方法
data_arr=read_data_from_excel(excel_path,"NVR")
print(data_arr)
边栏推荐
- 【生动理解】深度学习中常用的各项评价指标含义TP、FP、TN、FN、IoU、Accuracy
- 支付宝微信支付业务流程图
- 数字IC-1.9 吃透通信协议中状态机的代码编写套路
- Object含有Copy方法?
- Some considerations on operation / method overloading for thread to release lock resources
- I'm almost addicted to it. I can't sleep! Let a bug fuck me twice!
- fastadmin 安装后访问后台提示模块不存在
- Apache POI的读写
- 集合框架 泛型LinkedList TreeSet
- 多個類的設計
猜你喜欢
ucore lab3
Apache POI的读写
浏览器的markdown插件显示不了图片
Installation and usage of source insight tool
Object含有Copy方法?
初步认识pytorch
Getting started with webrtc: 12 Rtendpoint and webrtcendpoint under kurento
高等数学第七章微分方程
【生动理解】深度学习中常用的各项评价指标含义TP、FP、TN、FN、IoU、Accuracy
This, constructor, static, and inter call must be understood!
随机推荐
June 26, 2022 (LC 6100 counts the number of ways to place houses)
SVN版本控制器的安装及使用方法
VIM from dislike to dependence (19) -- substitution
集合框架 泛型LinkedList TreeSet
Understand neural network structure and optimization methods
Design of multiple classes
Enumeration? Constructor? Interview demo
ucore lab5
Reading and writing Apache poi
1098 insertion or heap sort (PAT class a)
高等数学第七章微分方程
A classic interview question covering 4 hot topics
win10为任意文件添加右键菜单
Shortcut key bug, reproducible (it seems that bug is the required function [funny.Gif])
Analysis of key technologies for live broadcast pain points -- second opening, clarity and fluency of the first frame
[ 扩散模型(Diffusion Model) ]
(original) custom drawable
Obsidian 一周使用心得(配置、主题和插件)
vim 从嫌弃到依赖(20)——global 命令
[MySQL basic] general syntax 1