简体   繁体   中英

Creation of excel file using python

有没有办法使用pywin32创建excel对象,即使在基于Windows的系统上没有安装MS-OFFICE套件?

This will do what you want.

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")

See this link for details.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM