python的excel操作工具之openpyxl
- 安装openpyxl
pip install openpyxl
- 创建xlsx文件
#!/usr/bin/env python2
# encoding: utf-8
from openpyxl import Workbook
def openpyxl_create():
wb = Workbook()
# 用active初始化一个表
ws = wb.active
# 在wb上创建一个表sheet,这是 分外创建的
#wsl = wb.create_sheet('Test')
ws.title = 'New Title'
ws.sheet_properties.tabColor = '1072BA'
wb.save('openpyxl_test.xlsx')