当前位置:网站首页>Three components of openpyxl
Three components of openpyxl
2022-07-05 21:29:00 【Nuoyiyou ~】
1. workbook
2. Worksheet
3. Cell
Read excel File data :
def read_excel(path): #1. Get the workbooks wk = openpyxl.load_workbook(path) # 2. Get worksheet sheets = wk.sheetnames for sheet in sheets: my_sheet = wk[sheet] result = list() # 3. Get the cell for row in range(2,my_sheet.max_row+1): result_row = list() for column in range(1,my_sheet.max_column+1): result_row.append(my_sheet.cell(row,column).value) result.append(result_row) print(result)
Write table data :
def create_excel(): #1. Create Workbook wk = openpyxl.Workbook() #2. Get current worksheet my_sheet = wk.active #3. Write data my_sheet.cell(1,1).value = "name" my_sheet.cell(1,2).value = "age" #4. Save table wk.save("user.xlsx")
Write multiple pieces of data :
def add_manyuData(path): #1. Open workbook in total wk = openpyxl.load_workbook(path) #2. Create sheet my_sheet = wk.create_sheet() #3. Write data once data = [1,2,3,4,5,6] my_sheet.append(data) #4. Save workbook wk.save(path)
边栏推荐
- vant 源码解析之 utils/index.ts 工具函数
- Clion configures Visual Studio (MSVC) and JOM multi-core compilation
- Talk about my fate with some programming languages
- Cross end solution to improve development efficiency rapidly
- Parker driver maintenance COMPAX controller maintenance cpx0200h
- Golang(1)|从环境准备到快速上手
- Introduction of ArcGIS grid resampling method
- Deployment of Jenkins under win7
- XML modeling
- one hundred and twenty-three thousand four hundred and fifty-six
猜你喜欢
EN 438-7建筑覆盖物装饰用层压板材产品—CE认证
Evolution of zhenai microservice underlying framework from open source component encapsulation to self-development
Learning robots have no way to start? Let me show you the current hot research directions of robots
MySQL 千万数据量深分页优化, 拒绝线上故障!
校招期间 准备面试算法岗位 该怎么做?
Opérations de lecture et d'écriture pour easyexcel
面试官:并发编程实战会吗?(线程控制操作详解)
Clion-MinGW编译后的exe文件添加ico图标
R语言【数据管理】
递归查询多级菜单数据
随机推荐
基于vertx-web-sstore-redis的改造实现vertx http应用的分布式session
Haas506 2.0 development tutorial - Alibaba cloud OTA - PAC firmware upgrade (only supports versions above 2.2)
Pytorch实战——MNIST数据集手写数字识别
Chapter 05_ Storage engine
递归查询多级菜单数据
Selenium's method of getting attribute values in DOM
MMAP
EasyExcel的讀寫操作
EN 438-7建筑覆盖物装饰用层压板材产品—CE认证
Sophomore personal development summary
SYSTEMd resolved enable debug log
Viewrootimpl and windowmanagerservice notes
@Validated基础参数校验、分组参数验证和嵌套参数验证
How to prepare for the algorithm interview and answer the algorithm interview questions
Teach yourself to train pytorch model to Caffe (III)
Ethereum ETH的奖励机制
Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture
Aitm2-0002 12s or 60s vertical combustion test
Deep merge object deep copy of vant source code parsing
Influence of oscilloscope probe on signal source impedance