Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does xlwt support xlsx Format

Tags:

python

xlwt

I have searched into google and found some contradiction. Does xlwt support xlsx file (MS office 2007). I heard that xlwt 0.7.4 support xlsx file. Does anyone tried xlsx file writing operation with xlwt 0.7.4

The purpose of this question is,I do not have permission to install library if I need to install I need to provide more detail info. I need to write xlsx file in python.So if anyone has done similar thing it will help to provide better inforamtion

I have looked into this wiki page. https://pypi.python.org/pypi/xlwt But did not find that it support xlsx file

or Should I use https://pypi.python.org/pypi/openpyxl for writing xlsx File

like image 603
user765443 Avatar asked Apr 01 '13 06:04

user765443


People also ask

Can Python read XLSX files?

OpenPyXL is a Python library created for reading and writing Excel 2010 xlsx/xlsm/xltx/xltm files. It can read both the . xlsx and . xlsm file formats, which includes support for charts, graphs, and other data visualizations.

Which format is better XLS or XLSX?

For compatibility, XLS has higher compatibility than XLSX. XLS is readable by all Microsoft Excel versions while XLSX is only readable by Excel 2007 and later versions. besides, XLS is able to hold the spreadsheets either including Macros or not, while XLSX isn't capable to support Macros.

Does Openpyxl work with XLS?

We can read data from xls or xlsx files using python programming and we can also write to xls or xlsx files using python programming. We do this by using the python package "openpyxl". The package "openpyxl" can be found in Python Package Index. So, we can easily install it with python pip.

How do you write data in Excel sheet using Python XLWT?

Using xlwt module, one can perform multiple operations on spreadsheet. For example, writing or modifying the data can be done in Python. Also, the user might have to go through various sheets and retrieve data based on some criteria or modify some rows and columns and do a lot of work.


3 Answers

The xlwt module doesn't support the xlsx format. The xlsx file format is completely different from the xls format supported by xlwt.

As an alternative have a look at XlsxWriter which is a Python module for creating xlsx files.

It supports a lot of Excel features. Have a look at the documentation or start with the examples.

like image 33
jmcnamara Avatar answered Oct 15 '22 10:10

jmcnamara


openpyxl is guaranteed to write xlsx files. From a cursory read through some of the xlwt code and docs/examples, I don't think xlwt supports xlsx. If openpyxl does what you need it to do, why look elsewhere?

Edit: with xlwt version 0.7.4 I attempted to save a file as sample.xlsx. Upon attempting to open it I got a not valid error message, so no .xlsx files for now.

like image 108
Cianan Sims Avatar answered Oct 15 '22 11:10

Cianan Sims


2021 update: xlrd has reached End of Life (due to security concerns in the xls format). You can use openpyxl for reading and writing data. You may also use xlsxwriter for writing, if you’re writing huge files and write performance is critical. See: https://openpyxl.readthedocs.io/en/stable/performance.html

2019 update: xlwt doesn't support xlsx Format.

XlsxWriter is 100% compatible with xlsx, well-maintained and has a good reputation.

For reading xlsx files, you can use xlrd.

You can also use Pandas if you've read+write requirements and want to create graphs and charts. (Pandas internally uses XlsxWriter modules to write the files).

P.S. - The last x in xlsx stands for XML. xlsx is a zipped Open XML file. Use xlsx wherever possible. xls is the old (proprietary) format, which doesn't have some advanced features like conditional formatting or freezing col/rows etc.

like image 33
Nitin Nain Avatar answered Oct 15 '22 10:10

Nitin Nain