当前位置:   article > 正文

Openpyxl 简要手册(一)_openpyxl中文手册pdf

openpyxl中文手册pdf

简介

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.
  • 1
  • 2
  • 3

兼容

Openpyxl不兼容旧版的xls文件。

安装openpyxl

~$: pip install openpyxl
  • 1

openpyxl用法

创建 .xlsx

创建工作簿Workbook

import openpyxl
workbook = openpyxl.Workbook()
  • 1
  • 2

创建工作表Sheet

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/834431
推荐阅读
相关标签
  

闽ICP备14008679号