当前位置:网站首页>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)
边栏推荐
- SQL common syntax records
- SQL knowledge leak detection
- Zhang Lijun: penetrating uncertainty depends on four "invariants"
- Chapter 05_ Storage engine
- Generics of TS
- 基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
- [case] Application of element display and hiding -- element mask
- Simple getting started example of Web Service
- ESP32
- 使用Aspect制作全局异常处理类
猜你喜欢
CLion配置visual studio(msvc)和JOM多核编译
ArcGIS栅格重采样方法介绍
Li Kou ----- the maximum profit of operating Ferris wheel
R language learning notes
Access Zadig self-test environment outside the cluster based on ingress controller (best practice)
MQ----activeMq
Influence of oscilloscope probe on signal source impedance
ArcGIS\QGIS无插件加载(无偏移)MapBox高清影像图
Two ways to realize video recording based on avfoundation
Incentive mechanism of Ethereum eth
随机推荐
办公遇到的问题--
水泥胶黏剂BS 476-4 不燃性测试
EN 438-7建筑覆盖物装饰用层压板材产品—CE认证
vant 源码解析 之深层 合并对象 深拷贝
冯唐“春风十里不如你”数字藏品,7月8日登录希壤!
Add ICO icon to clion MinGW compiled EXE file
Learning notes of statistical learning methods -- Chapter 1 Introduction to statistical learning methods
Two ways to realize video recording based on avfoundation
PostGIS installation geographic information extension
Establishment of terminal security capability verification environment and penetration test records
力扣------经营摩天轮的最大利润
SYSTEMd resolved enable debug log
selenium 查找b或p标签的内容
2022-07-03-CKA-粉丝反馈最新情况
Aitm2-0002 12s or 60s vertical combustion test
Which securities company is better and which platform is safer for stock account opening
int GetMonth( ) const throw( );后面的throw( )什么意思?
Access Zadig self-test environment outside the cluster based on ingress controller (best practice)
MySQL deep paging optimization with tens of millions of data, and online failure is rejected!
Sequence alignment