来源:python中国网 时间:2020-04-04

  openpyxl创建excel非常简单,只要导入workbook类就可以了。在Excel文档创建后会默认有一个名字为Sheet的工作表。看官网说明

  Create a workbook

  There is no need to create a file on the filesystem to get started with openpyxl. Just import the Workbook class and start work:

  from openpyxl import Workbook

     wb = Workbook()

  创建并保存为test.xlsx代码:

# -*- coding: utf-8 -*-
from openpyxl import Workbook

wb = Workbook()
wb.save('test.xlsx')




  如图: