Python:写入 Excel 2007+ 文件(.xlsx 文件)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4257771/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 14:57:44  来源:igfitidea点击:

Python: Writing to Excel 2007+ files (.xlsx files)

pythonexcelexcel-2007openpyxl

提问by Jonathan

Is there a Python module that writes Excel 2007+ files?
I'm interested in writing a file longer than 65535 lines and only Excel 2007+ supports it.

是否有编写 Excel 2007+ 文件的 Python 模块?
我对编写超过 65535 行的文件很感兴趣,并且只有 Excel 2007+ 支持它。

采纳答案by user225312

There are two libraries you can take a look at.

您可以查看两个库。

Python-xlsxand PyXLSX

Python-xlsxPyXLSX

EDIT: As the comments mention, for writing you check out openpyxl

编辑:正如评论中提到的,为了写作,你可以查看openpyxl

回答by ykatchou

So you want to write xlsx file, into my mind the Microsoft.office.excel.interop dll come to my mind, but not use it on a server.

所以你想写 xlsx 文件,我想到了 Microsoft.office.excel.interop dll,但不要在服务器上使用它。

I know you can call dll from python : http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel(office.11).aspx

我知道你可以从 python 调用 dll:http: //msdn.microsoft.com/en-us/library/microsoft.office.interop.excel(office.11​​).aspx

回答by Mark Baker

Take a look at Eric' Gazoni's openpyxlproject. The code can be found on bitbucket.

看看 Eric' Gazoni 的openpyxl项目。代码可以在bitbucket上找到。

回答by John Machin

If you are on Windows and have Excel 2007+ installed, you should be able to use pywin32 and COM to write XLSX files using almost the same code as you would would to write XLS files ... just change the "save as ...." part at the end.

如果您使用的是 Windows 并安装了 Excel 2007+,您应该能够使用 pywin32 和 COM 使用几乎与编写 XLS 文件相同的代码编写 XLSX 文件......只需更改“另存为...... .”结尾的部分。

Probably, you can also write XLSX files using Excel 2003 with the freely downloadable add-on kit but the number of rows per sheet would be limited to 64K.

或许,您也可以使用 Excel 2003 和可免费下载的附加工具包编写 XLSX 文件,但每张纸的行数将限制为 64K。

回答by chmullig

You should take a look at xlsxcessive. It's for writing xlsx files, and is, perhaps, a bit more pythonic.

你应该看看xlsxcessive。它用于编写 xlsx 文件,并且可能更像 pythonic。

回答by googed

Pyvot: http://packages.python.org/Pyvot/tutorial.html, although it is only for Excel 2010+

Pyvot:http://packages.python.org/Pyvot/tutorial.html ,虽然它仅适用于 Excel 2010+

回答by jmcnamara

The XlsxWriterPython module writes 2007+ xlsx files.

XlsxWriterPython模块写入2007+ XLSX文件。