使用 python 创建 excel 文件

Creation of excel file using python

即使在基于 windows 的系统上未安装 MS-OFFICE 套件,是否有任何方法可以使用 pywin32 创建 excel 对象?

这会做你想做的事。

from openpyxl import Workbook
wb = Workbook()

# grab the active worksheet
ws = wb.active

# Data can be assigned directly to cells
ws['A1'] = 42

# Rows can also be appended
ws.append([1, 2, 3])

# Python types will automatically be converted
import datetime
ws['A2'] = datetime.datetime.now()

# Save the file
wb.save("C:\Users\your_path_here\Desktop\sample.xlsx")

有关详细信息,请参阅此 link。

https://pypi.python.org/pypi/openpyxl