什么是在Python中处理Excel文件的最佳库?

huangapple go评论98阅读模式
英文:

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

问题

我有一个包含许多工作表和工作表内相互链接公式的大型Excel文件。我需要使用代码在一个工作表中填入输入,然后重新计算所有公式,以从另一个工作表中获取输出。

我能够使用Java中的Apache POI来实现这一点,但公式重新计算速度太慢。正在寻找在Python中实现相同功能的库。

英文:

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.

答案1

得分: 8

最好的两个库,我在使用过程中与它们一起工作,分别是XlsxWriterxlwings
两者都运行流畅高效,且与Python和Excel兼容。

xlwings有两个版本,FreePro(付费版本)Free版本具有完整的功能,几乎可以处理您需要在Excel文件中进行的任何操作。付费版本可以获得更多功能和支持,但开发人员(而非普通用户)大部分时间不需要这些功能。

另一方面,XlsxWriter也是一个很好的选择,其用户社区最近增长迅速。它支持您处理Excel文件所需的一切。

这两个库都可以通过pipconda轻松安装。

其他库,如xlrdxlwt,过去是为处理旧版本(.xls)文件而设计的。它们无法与我提到的另外两个库相比较。

OpenPyXl也是一个不错的库,可以满足您大部分的需求。该库需要更多的支持才能发展壮大。在我看来,它还没有完全成熟。

Pandaspyexcel库也适用于从Excel文件读取和写入数据。我更倾向于使用Pandas,因为它是一个成熟且高效的库,可以处理大数据。pyexcel是一个包装器API,功能不如Pandas强大,使用起来更加复杂。

PyXLL是一个专业的库,几乎可以处理用户在Excel中需要的所有功能。其中一个著名的Python发行公司Enthought支持这个库。不幸的是,它没有免费或社区版本,您只能选择使用30天的付费试用版。之后,您必须每月支付至少29美元。它功能强大,但对于单个开发者来说是一个昂贵的选择。

当然,还有更多用于处理Excel文件的包装器API,但我提到了最成熟和最流行的库。

英文:

The best ones as I worked with them are XlsxWriter and xlwings.
Both work smoothly and efficiently, and they are compatible with Python and Excel.

Xlwings has two versions, Free and Pro (paid version). The 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 user community has been growing fast recently. It supports all you need to work with an Excel file.

Both can be installed simply with pip and conda.

The other libraries, such as xlrd and 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, supports 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.

答案2

得分: 3

以下是一些可以实现这一功能的库。根据您的需求建议对它们进行详细了解。

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

它们都与 Excel 非常兼容。您可以尝试使用这些库。

英文:

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.

答案3

得分: 2

Sure, here's the translation:

我想要为Mayanks添加一些更多的库:

  1. 用于数据可视化的matplotlib
  2. Numpy
  3. OpenpyXl
  4. xlrd
  5. xlwt
  6. XlsxWriter

你可以逐个浏览并选择适合你需求的库。

英文:

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

huangapple
  • 本文由 发表于 2020年5月5日 16:56:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/61609377.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定