- xlrd can only be used to read files, not to write files;
- xlwt can only be used to write files (can only create files, not open existing files), and cannot be used to read files; but it can overwrite existing files when saving.
- xlutils uses the .copy.copy method to copy the files read by xlrd and then process them to xlwt ; it is equivalent to building a bridge between xlrd and xlwt ;
- xlrd version 1.2.0 can read .xls files and .xlsx files at the same time;
- After xlrd version 2.0.0 , it can only be used to read .xls files, and no longer supports .xlsx files;
- The more complicated one is xlrd , followed by xlwt , and the least content is xlutils , just use the .copy.copy method;
Use of xlwt:
Form and write, set cell style, set width/background color/alignment, add formula/hyperlink/date, merge rows and columns, add border xlwt operation excel tutorial of python package - sunnyeden - blog garden master how to operate excel https://www.cnblogs.com/sunnyeden/p/16054204.html
Use of xlutils
1. Copy the original file
2. Obtain the information of the original workbook before copying 3. Obtain
the information of the new workbook after copying 4.
Modify the file content directly after copying 5.
Obtain the index coordinates of all cells 6.
Modify the elements in the
cells 7. (Change) function: read the cell index and modify the elements in the cell 8. (Increase) function: add multiple pieces of
data
Excel common operation encapsulation function:
https://www.jb51.net/article/267653.htm JS+Selenium+excel additional writing, using python to successfully crawl any commodity in Jingdong-Knowledge
which one to choose
- To process small and medium-sized data, use win32com package or xlwings package, they can basically do what VBA can do
- To handle large data, use the pandas package
- For development, use the openpyxl package, it does not depend on Excel, it can work normally without Excel installed on the computer, and it is also cross-platform
Although openpyxl has powerful functions for operating Excel, its read and write performance is too bad, especially when writing large tables, it will take up a lot of memory. After enabling the read_only and write_only modes, its performance has been greatly improved, especially the performance of reading has been greatly improved, making it almost time-consuming.
Pandas regards Excel as a container for data reading and writing, serving its powerful data analysis. Therefore, its reading and writing performance is quite satisfactory, but its compatibility with Excel files is the best. It supports reading and writing of .xls and .xlsx files, and supports a single worksheet in a read-only table.
The library that also supports this function is xlrd, but xlrd only supports reading, not writing, and its performance is not outstanding. It needs to cooperate with xlutils to perform Excel operations.
xlsxwriter has a single function and is generally used to create .xlsx files with moderate writing performance.
Link: https://www.zhihu.com/question/504963568/answer/2650990775
Link: https://www.zhihu.com/question/504963568/answer/2650990775
- xlrd is a library for reading data and formatting information from Excel files, supporting .xls and .xlsx files. Official documentation: http://xlrd.readthedocs.io/en/latest/
- xlwt is a library for writing data and formatting information to old Excel files (like .xls). Official documentation: https://xlwt.readthedocs.io/en/latest/
- xlutils is a library for processing Excel files, which depends on xlrd and xlwt. It only supports operations on .xls files. Official documentation: http://xlutils.readthedocs.io/en/latest/
- xlwings is simple and powerful, easy to use, and can replace VBA. xlwings can support .xls reading and reading and writing of .xlsx files. Official documentation: http://docs.xlwings.org/en/stable/index.html
- XlsxWriter is a module for writing .xlsx file format, but not for reading and modifying Excel files. Official documentation: https://xlsxwriter.readthedocs.io/
- openpyxl is a library for reading and writing Excel 2010 xlsx/xlsm/xltx/xltm files. Official documentation: https://openpyxl.readthedocs.io/en/stable/
- Pandas is a powerful module for data processing and analysis, and sometimes it can be used to automate Excel, official documentation: http://pandas.pydata.org/