赞
踩
Openpyxl 是用来读写Excel 2010 xlsx/xlsm/xltx/xltm文件的库。
Documentations of Openpyxl on readthedocs.io: https://openpyxl.readthedocs.io/en/stable/
Security
By default openpyxl does not guard against quadratic blowup or billion laughs xml attacks. To guard against these attacks install defusedxml.
Openpyxl不兼容旧版的xls文件。
~$: pip install openpyxl
import openpyxl
workbook = openpyxl.Workbook()
xlsx文件工作表的索引是从0开始的。
# 第一个工作表后面创建工作表
sheet_name = ‘sheet1’
sheet = workbook.create_sheet(sheet_name)
# Equal to the following
# 工作表名称列表
sheet_names = workbook.get_sheet_names()
sheet = workbook.create_sheet(sheet_name, index=len(sheet_names))
# 第一个工作表前创建
sheet = workbook.create_sheet(sheet_name, 0)
# sheet = workboo
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。