直接贴代码,注释很清楚

import openpyxl
import time
import os
import threading
class mExcelManager:def __init__(self,filerootpath,filename):self.allmodels = []self.zimu = ["A", "B", "C", "D", "E", "F","G", "H", "I", "J", "K", "L","M", "N", "O", "P", "Q", "R","S", "T", "U", "V", "W", "X","Y", "Z"]self.filerootpath = filerootpathself.filename = filenameself.result_excel_name = ""# 读取excel表格def read_excel_data(self,defaultmax_column=12):wb = openpyxl.load_workbook(filename=self.filename, read_only=True, )ws = wb.activemodel = []print(ws.max_row)for index in range(2, ws.max_row):if model.__len__() > 1:self.allmodels.append(model)model = []# print("read datas =>")if self.allmodels.__len__() == 200:time.sleep(0.1)continuefor rowindex in range(1,defaultmax_column):data = ws[""+self.zimu[rowindex] + str(index)].valuemodel.append(data)#写入excel表格,写入速度比较慢def write_to_excel(self,file_path_name):wb = openpyxl.load_workbook(filename=file_path_name)ws = wb.activestart_time = time.time()count = 0while (True):if self.allmodels.__len__() > 0:model = self.allmodels.pop(0)ws.append(model)wb.save(file_path_name)count = count + 1currenttime = time.time()useseconds = int(currenttime) - int(start_time)print("write datas "+ " time:" + str(useseconds) +" count: " + str(count))else:time.sleep(0.01)continue# 创建表格def create_excel(self,filename,sheet_name = "",title = ""):self.result_excel_name = filenamewb = openpyxl.Workbook()if sheet_name.__len__()>0:wb.create_sheet("Name", 0)ws = wb.activeif title.__len__() >0:ws.title = "bob"wb.save(filename=filename)

python3 使用openpyxl 处理excel表格数据相关推荐

  1. python3读取excel数据-Python3读取和写入excel表格数据的示例代码

    python操作excel主要用到 xlrd 和 xlwt 这两个库,xlrd读取excel表格数据, 支持 xlsx和xls格式的excel表格 :xlwt写入excel表格数据: 一.python ...

  2. python使用openpyxl处理excel表格数据

    python使用openpyxl处理excel表格数据 前言 一.安装openpyxl包 二.读取excel数据 1. 获取excel表格的页码 2. 获取excel表格某一行的数据 3. 获取exc ...

  3. Python3读取和写入excel表格数据

    目录 一.python读取excel表格数据 1.读取excel表格数据常用操作 2.xlrd模块的主要操作 3.读取单元格内容为日期时间的方式 4. 读取合并单元格的数据 二.python写入exc ...

  4. python 显示表格数据_python显示excel表格数据-怎么用python读取excel表格的数据

    怎么用python读取excel表格的数据 #导入包 import xlrd #设置路径 path='C:\\Users\\jyjh\\Desktop\\datap.xlsx' #打开 data=xl ...

  5. Python3 编写处理Excel表格数据筛选脚本用到的一些方法

    记录下之前用python3 写的一个处理Excel表格数据筛选脚本用到的一些方法. 本文内容比较杂,可按需跳转翻看. pandas是一个内容十分丰富的库,我也只不过用到其中处理excel的方法,对这个 ...

  6. python3 写入excel表格数据_Python3读取和写入excel表格数据

    目录 python操作excel主要用到 xlrd和xlwt 这两个库,xlrd读取excel表格数据, 支持 xlsx和xls格式的excel表格 :xlwt写入excel表格数据: 一.pytho ...

  7. python导入excel表格-Python 将Excel表格数据导入MySQL数据库

    今天分享一个刚刚完成的Python脚本,一个实用的小技能,就是利用Python代码,将EXCEL表格数据导入到MySQL数据库中!话不多说,下面代码示例. Excel表格数据.jpg 1示例代码: i ...

  8. Python 使用 pandas 和 openpyxl 读取 excel 表格(读取指定行和列)

    前言 在使用Python处理表格时,pandas 和 openpyxl是使用最多的两个库.现在我来简单记录一下这两个库在处理Excel表格时一些常用操作. 1.使用pandas操作excel表格 (1 ...

  9. python读excel表格数据绘制图表_Python读取Excel数据生成图表 v2.0

    原博文 2020-06-15 15:09 − ## Python读取Excel数据生成图表 v2.0 ## 一.需求背景 自己一直在做一个周基金定投模拟,每周需要添加一行数据,并生成图表.以前一直是用 ...

最新文章

  1. 第四课.LinuxShell编程
  2. android rebound平移,Android 仿 IOS 拖拽回弹之进阶 ReboundFrameLayout
  3. 【Java系列】从JVM角度解析Java核心类String的不可变特性
  4. OCP 042全真试题讲解
  5. 【Flask】RESTful的响应处理
  6. boost::transform_iterator用法的测试程序
  7. CanalSharp.AspNetCore v0.0.4-支持输出到MongoDB
  8. 前端模板引擎artTemplate---高性能JavaScript模板引擎
  9. Hadoop学习之路(十三)MapReduce的初识
  10. 再一次站在捆绑销售风口的携程该何去何从?
  11. .NET常见错误大全
  12. Windows Server 2008 优化
  13. 【BZOJ2654】tree
  14. 屏幕镜像显示无法连接服务器,苹果屏幕镜像连接失败原因
  15. 电脑网线,电脑网线主要分类
  16. vue3.Vue实例
  17. python地理空间_Python批量下载地理空间数据云数据!Python无所不能!-站长资讯中心...
  18. 2018 抖音热门歌曲大全
  19. 消防信号总线原理_消防总线隔离模块作用及工作原理?
  20. 美团程序员提问:应届生,工资34k,算多吗?

热门文章

  1. 软件测试面试--说一个印象最深的bug?
  2. java判断垃圾已回收_[译] 现代垃圾回收
  3. (PHP)获取微信支付平台证书步骤
  4. keil c语言 延迟程序,Keil C51程序设计中几种精确延时方法
  5. 学习笔记:min-width和min-height
  6. 通信原理-第9章-数字信号的最佳接收
  7. 5步搭建免费图床(CDN图床)再也不用担心网站网速与内存了
  8. OpenLayers中文文档2栅格重投影
  9. 基于VB的COM编程入门教程
  10. 云南鲁甸县附近发生6.5级地震 震源深度12千米