Reputation: 107072
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.
Upvotes: 15
Views: 22323
Reputation: 1298
This should give an idea how to do that:
import xlsxwriter
workbook = xlsxwriter.Workbook("output_file.xlsx"))
# new sheet
worksheet = workbook.add_worksheet("sheet_name")
# Add a number format: 3 digits precision
precision = workbook.add_format({'num_format': '0.000'})
for(iterate your data):
worksheet.write(row, col, title)
worksheet.write_number(row, col, value, precision)
...
workbook.close()
Upvotes: 1
Reputation: 11
Pyvot: http://packages.python.org/Pyvot/tutorial.html, although it is only for Excel 2010+
Upvotes: 1
Reputation: 13406
You should take a look at xlsxcessive. It's for writing xlsx files, and is, perhaps, a bit more pythonic.
Upvotes: 8
Reputation: 82924
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.
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.
Upvotes: 1
Reputation: 131567
There are two libraries you can take a look at.
Python-xlsx and PyXLSX
EDIT: As the comments mention, for writing you check out openpyxl
Upvotes: 10
Reputation: 212402
Take a look at Eric' Gazoni's openpyxl project. The code can be found on bitbucket.
Upvotes: 17
Reputation: 3727
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.
I know you can call dll from python : http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel(office.11).aspx
Upvotes: 0