常见库简介
xlrd
xlrd 是一个从 Excel 文件读取数据和格式化信息的库,支持.xls 以及.xlsx 文件。
http://xlrd.readthedocs.io/en/latest/
1、xlrd 支持.xls,.xlsx 文件的读
2、通过设置 on_demand 变量使 open_workbook() 函数只加载那些需要的 sheet,从而节省时间和内存(该方法对.xlsx 文件无效)。
3、xlrd.Book 对象有一个 unload_sheet 方法,它将从内存中卸载工作表,由工作表索引或工作表名称指定(该方法对.xlsx 文件无效)
xlwt
xlwt 是一个用于将数据和格式化信息写入旧 Excel 文件的库(如.xls)。
https://xlwt.readthedocs.io/en/latest/
1、xlwt 支持.xls 文件写。
xlutils
xlutils 是一个处理 Excel 文件的库,依赖于 xlrd 和 xlwt。
http://xlutils.readthedocs.io/en/latest/
1、xlutils 支持.xls 文件。
2、支持 Excel 操作。
xlwings
xlwings 是一个可以实现从 Excel 调用 Python,也可在 python 中调用 Excel 的库。
http://docs.xlwings.org/en/stable/index.html
1、xlwings 支持.xls 读,支持.xlsx 文件读写。
2、支持 Excel 操作。
3、支持 VBA。
4、强大的转换器可以处理大部分数据类型,包括在两个方向上的 numpy array 和 pandas DataFrame。
openpyxl
openpyxl 是一个用于读取和编写 Excel 2010 xlsx/xlsm/xltx/xltm 文件的库。
https://openpyxl.readthedocs.io/en/stable/
1、openpyxl 支持.xlsx 文件的读写。
2、支持 Excel 操作。
3、加载大.xlsx 文件可以使用 read_only 模式。
4、写入大.xlsx 文件可以使用 write_only 模式。
xlsxwriter
xlsxwriter 是一个用于创建 Excel .xlsx 文件的库。
https://xlsxwriter.readthedocs.io/
1、xlswriter 支持.xlsx 文件的写。
2、支持 VBA。
3、写入大.xlsx 文件时使用内存优化模式。
win32com
win32com 库存在于 pywin32 中,是一个读写和处理 Excel 文件的库。
http://pythonexcels.com/pytho