下载资源后端资源详情
python实战项目:Python从Excel表中批量复制粘贴数据到新表.zip
大小:242.34KB
价格:48积分
下载量:0
评分:
5.0
上传者:weixin_57950978
更新日期:2025-09-22

python 入门项目实战:Python从Excel表中查找指定数据填入新表

资源文件列表(大概)

文件名
大小
python实战项目:Python从Excel表中批量复制粘贴数据到新表/
-
python实战项目:Python从Excel表中批量复制粘贴数据到新表/统计表模板.xlsx
8.99KB
python实战项目:Python从Excel表中批量复制粘贴数据到新表/images/
-
python实战项目:Python从Excel表中批量复制粘贴数据到新表/images/problem.png
216.84KB
python实战项目:Python从Excel表中批量复制粘贴数据到新表/images/theresult.PNG
12.91KB
python实战项目:Python从Excel表中批量复制粘贴数据到新表/Python从Excel表中查找指定数据填入新表.ipynb
5.02KB
python实战项目:Python从Excel表中批量复制粘贴数据到新表/统计表.xlsx
5.17KB
python实战项目:Python从Excel表中批量复制粘贴数据到新表/example71.py
1.35KB
python实战项目:Python从Excel表中批量复制粘贴数据到新表/原表.xls
35KB

资源内容介绍

一个简单的python入门实战,学习使用Python批量化从Excel表中查找指定数据填入新表,
#读取xls文件中的数据import xlrdfile = "原表.xls"wb = xlrd.open_workbook(file) #读取工作簿ws = wb.sheets()[0] #选第一个工作表data = []for row in range(7, ws.nrows): name = ws.cell(row, 1).value.strip() #科室名称 total1 = ws.cell(row, 2).value #总计 total2 = ws.cell(row, 3).value #计 avg = ws.cell(row, 20).value #平均每日人次 info_list=[name,total1,total2,avg] if info_list[0] != "": #去除空数据 data.append(info_list)from openpyxl import load_workbookfrom openpyxl.styles import Border, Side, PatternFill, Font, GradientFill, Alignment #设置单元格格式thin = Side(border_style="thin", color="000000")#定义边框粗细及颜色file = "统计表模板.xlsx"wb = load_workbook(file)ws = wb.active#写入数据for i in data: ws.append(i) #设置字号,对齐,缩小字体填充,加边框#Font(bold=True)可加粗字体for row_number in range(3, ws.max_row+1): ws.row_dimensions[row_number].height = 25 #设置行高 for col_number in range(1,5): c = ws.cell(row=row_number,column=col_number) c.font = Font(size=11,bold=True) c.border = Border(top=thin, left=thin, right=thin, bottom=thin) c.alignment = Alignment(horizontal="center", vertical="center") wb.save("统计表.xlsx")

用户评论 (0)

发表评论

captcha