Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best library in python to deal with excel files? [closed]

I have big excel with lot of sheets and formulas interlinked within the sheets. I need to populate input in one sheet using the code and recalculate all the formulas to get my output from another sheet.

I am able to do this with apache POI using Java but it is too slow in formula recalculation. Looking for libraries in Python to do the same.

like image 505
Aniket Kalamkar Avatar asked May 05 '20 08:05

Aniket Kalamkar


People also ask

How do I close open Excel file in Python?

Python has a close() method to close a file. The close() method can be called more than once and if any operation is performed on a closed file it raises a ValueError.

Which of the following Python library can be used to open an Excel file?

Openpyxl is a Python library for reading and writing Excel (with extension xlsx/xlsm/xltx/xltm) files. The openpyxl module allows Python program to read and modify Excel files.

Is XlsxWriter faster than openpyxl?

If you are working with large files or are particularly concerned about speed then you may find XlsxWriter a better choice than OpenPyXL. XlsxWriter is a Python module that can be used to write text, numbers, formulas and hyperlinks to multiple worksheets in an Excel 2007+ XLSX file.

What are the best Python libraries for dealing with Excel spreadsheets?

The best python libraries for dealing with Excel spreadsheets are introduced below. It is a Python Library developed by Eric Gazoni and Charlie Clark to read and write Excel xlsx/xlsm/xltm/xltx files without using the Excel software. It is the most widely used library for python-excel purposes.

What is xlsx library in Python?

It is a Python Library developed by Eric Gazoni and Charlie Clark to read and write Excel xlsx/xlsm/xltm/xltx files without using the Excel software. It is the most widely used library for python-excel purposes.

How do I work with Excel files in Python?

Utilities for working with Excel files that require both xlrd and xlwt. openpyxl is a Python library to read/write Excel 2010 xlsx/xlsm/xltx/xltm files. Transpose your Excel calculations into python for better performances and scaling.

What is openpyxl in Python?

openpyxl is a Python Library developed by Eric Gazoni and Charlie Clark to read and write Excel xlsx/xlsm/xltm/xltx files without using the Excel software. It is an open source excel libs and most widely used library for excel operation.The openpyxl is the default reader for Python Pandas. You can also read : How To Use Regex With Python


3 Answers

The best ones as I worked with them are XlsxWriter and Xlwings. Both of them are working smoothly and efficiently, and they have good compatibility between Python and Excel.

Xlwings has two versions, Free and Pro (paid version). Free version has the complete ability and can do almost anything you need to work with an Excel file. With the paid version, you can get more functionality and support, which developers (not regular users) do not need most of the time.

On the other hand, XlsxWriter is also an excellent choice, and its users' community is growing fast recently. It supports all you need to work with an excel file.

Both of them can be installed simply with pip and conda.

The other libraries, such as xlrd, xlwt are designed in the past for handling the old version (.xls) files. They are not comparable with the other two libraries that I mentioned.

OpenPyXl also is a decent library that can handle most of your needs. The library needs more support to grow. In my opinion, it is not well mature yet.

Pandas and pyexcel libraries are also suitable for reading and writing data to an Excel file. I prefer Pandas because it is a mature and fast library that can handle big data. pyexcel is a wrapper API that is not capable as Pandas, and working with it is more complicated.

PyXLL is a professional library that can handle almost everything a user wants in Excel with Python. One of the famous companies working on Python distributions, Enthought, is supporting the library. Unfortunately, there is no free or community version of it, and you can only choose a 30 days trial of the pro version. After that, you must pay at least $29 per month. It is powerful, but it is an expensive choice for a single developer.

Of course, there are more Libraries, Wrapers and APIs for handling excel files, but I mentioned the most mature and popular libraries.

like image 100
Reza K Ghazi Avatar answered Oct 19 '22 18:10

Reza K Ghazi


Below are a few libraries which do that. Recommend going through them as per your requirements.

  1. Pycel
  2. formulas
  3. Pandas
  4. xlwt
  5. Openpyxl

They all blend with excel really well. You can try these out.

like image 3
Mayank Porwal Avatar answered Oct 19 '22 20:10

Mayank Porwal


I would like to add some more libraries to Mayanks

  1. matplotlib for data visualisation
  2. Numpy
  3. OpenpyXl
  4. xlrd
  5. xlwt
  6. XlsxWriter

You can go through each and choose what suits best to your needs

like image 2
Adarsh Avatar answered Oct 19 '22 18:10

Adarsh