python处理Excel - xlrd xlwr openpyxl
python处理Excel - xlrd xlwr openpyxl
1 xlrd和xlwt
Todo: 使用xlrd和xlwt读写Excel文件的方法和示例代码,待续。。。
参考链接:
Creating Microsoft Excel Spreadsheets with Python and xlwt:https://www.blog.pythonlibrary.org/2014/03/24/creating-microsoft-excel-spreadsheets-with-python-and-xlwt/
前期使用xlrd和xlwt读写excel表格,现写入excel时出现问题:
ValueError: row index was 65536, not allowed by .xls format
xlwt只能处理.xls格式的Excel,即2003之前的版本,Excel2003只能支持65535行数据,实际应用超出该范围,因此抛出错误[1]。
2 openpyxl
openpyxl: A Python library to read/write Excel 2010 xlsx/xlsm files
Sample code:
from openpyxl import Workbook
wb = Workbook() # grab the active worksheet
ws = wb.active # Data can be assigned directly to cells
ws['A1'] = 42 # Rows can also be appended
ws.append([1, 2, 3]) # Python types will automatically be converted
import datetime
ws['A2'] = datetime.datetime.now() # Save the file
wb.save("sample.xlsx")
openpyxl tutorial: https://openpyxl.readthedocs.io/en/stable/tutorial.html
核心代码:
# Create a workbook from openpyxl import Workbook
wb = Workbook()
ws = wb.active # Playing with data
## Accessing one cell
ws['A4'] = 4
c = ws['A4']
d = ws.cell(row=4, column=2, value=10)
for x in range(1,101):
for y in range(1,101):
ws.cell(x, y, value)
## Accessing many cells
cell_range = ws['A1':'C2'] # Saving to a file
wb.save('balances.xlsx')
参考链接:
[1] ValueError: row index was 65536, not allowed by .xls format: https://stackoverflow.com/questions/45741670/valueerror-row-index-was-65536-not-allowed-by-xls-format
python处理Excel - xlrd xlwr openpyxl的更多相关文章
- python操作excel xlrd和xlwt的使用
最近遇到一个情景,就是定期生成并发送服务器使用情况报表,按照不同维度统计,涉及python对excel的操作,上网搜罗了一番,大多大同小异,而且不太能满足需求,不过经过一番对源码的"研究&q ...
- Python读excel——xlrd
Python读excel——xlrd Python读取Excel表格,相比xlwt来说,xlrd提供的接口比较多,但过程也有几个比较麻烦的问题,比如读取日期.读合并单元格内容.下面先看看基本的操作: ...
- python基础===Excel处理库openpyxl
openpyxl是一个第三方库,可以处理xlsx格式的Excel文件. 安装: pip install openpyxl 对如下excel进行读取操作,如图: from openpyxl import ...
- python读取excel(xlrd)
一.安装xlrd模块: 1.mac下打开终端输入命令: pip install xlrd 2.验证安装是否成功: 在mac终端输入 python 进入python环境 然后输入 import xl ...
- python的excel处理之openpyxl
一.颜色处理 cell = sheet.cell(row, col)font = Font(size=12, bold=False, name='Arial', color=colors.BLACK) ...
- python 读取excel Xlrd模块
1. 安装xlrd模块 我使用pip安装: cmd ->切换到pip安装所在路径->pip install xlrd->回车 2. 使用 2.1:打开Excel表 导入模块: im ...
- 27.python中excel处理库openpyxl使用详解
openpyxl是一个第三方库,可以处理xlsx格式的Excel文件.pip install openpyxl安装. 读取Excel文件 需要导入相关函数 ? 1 2 3 from openpyxl ...
- python——新excel模块之openpyxl
1.安装 pip install openpyxl 2.新建文件 book=openpyxl.Workbook() 3.打开sheet页(两种方式) sheet=book.active #默认的she ...
- python操作Excel的库openpyxl
http://openpyxl.readthedocs.io/en/default/tutorial.html 这里先上该库的文档镇文. 1,遇到合并后的单元格信息读取的问题,通过使用cell中off ...
随机推荐
- jdbc中的sql注入
- using 关键字的作用
我们都知道可以使用using关键字引入命名空间,例如:using namespace std; using还有个作用是在子类中引入父类成员函数. 1) 当子类没有定义和父类同名的函数(virtual也 ...
- Spring AOP概念理解
1.我所知道的aop 初看aop,上来就是一大堆术语,而且还有个拉风的名字,面向切面编程,都说是OOP的一种有益补充等等.一下子让你不知所措,心想着:怪不得很多人都和我说aop多难多难.当我看进去以后 ...
- B. Nirvana Codeforces Round #549 (Div. 2) (递归dfs)
---恢复内容开始--- Kurt reaches nirvana when he finds the product of all the digits of some positive integ ...
- PHP文件上传大小限制问题
一.Thinkphp方面限制 $upload->maxSize = 31457280 ; //设置附件上传大小 二.七牛方面限制: 'UPLOAD_FILE_QINIU' => ...
- 面试中遇到的原生js题总结
最近面试,遇到很多js相关的面试题,总结一下. 1.js 去重 1) indexOf Array.prototype.unique = function(){ var result = []; var ...
- 关于UITabBarController的设置(iOS 开发)
1.设置图片(选中以及未选中) UITabBarItem *TuiJianItem=[[UITabBarItem alloc]initWithTitle:@"我的" image:[ ...
- flask之一些凌乱知识点
本篇导航: session组件 上下文与内置函数 pymysql问题 模版问题 一.session组件 1.session组件简介 flask-session是flask框架的session组件,由于 ...
- [LeetCode] Binary Trees With Factors 带因子的二叉树
Given an array of unique integers, each integer is strictly greater than 1. We make a binary tree us ...
- 图片上传 new FormData() ,new FileReader()
多图片和单图片取决于 multiple属性,下面来介绍下 new FileReader() reader.readAsDataUrl(file[0]) 可以看到文件是Base64的, let fd = ...