简体   繁体   English

从Python创建Excel XML文件

[英]Create Excel XML files from Python

I need to create Excel XML files from Python. 我需要从Python创建Excel XML文件。

The Excel XML format is fairly simple. Excel XML格式非常简单。 I looked at aa sample xml file saved from Excel 2003 and it is fairly simple. 我查看了从Excel 2003保存的示例xml文件,它非常简单。

I'm looking for aa Pythonic, ready made library to create such xml files instead of reinventing one. 我正在寻找一个Pythonic,现成的库来创建这样的xml文件,而不是重新发明一个。

Something that I can use as below: 我可以使用的东西如下:

book = Expy.Workbook()
s1 = book.add_sheet()
s1[0, 2] = "A3"
s1[0, 0] = 12
s1[0, 9] = Expy.Formula("=Sum(A1:A3)")

book.write("excelfile.xml")

Anybody know of something like that? 有谁知道这样的事情?

xlwt seems outdated, supporting python 2.x only, and seems to write xls files, not xml. xlwt似乎过时了,只支持python 2.x,似乎写xls文件,而不是xml。

尝试一下pythonOffice

If you are on windows with Excel installed, you could look into Excel Automation. 如果您安装了Excel的Windows,则可以查看Excel Automation。

from win32com import client
excel_app = client.Dispatch("Excel.Application")
# check VBA documentation on automating excel...

xlwt will write Excel files from python, but I'm not sure if it handles the newer XML file formats. xlwt将从python中编写Excel文件,但我不确定它是否处理较新的XML文件格式。 http://pypi.python.org/pypi/xlwt http://pypi.python.org/pypi/xlwt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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