簡體   English   中英

使用python創建excel文件

[英]Creation of excel file using python

有沒有辦法使用pywin32創建excel對象,即使在基於Windows的系統上沒有安裝MS-OFFICE套件?

這將做你想要的。

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

請參閱此鏈接了解詳情。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM