Language/Python

python excel xls xlsx

TechNote.kr 2015. 8. 9. 21:55
728x90

Python 으로 xls, xlsx file을 수정하는 방법으로 아래의 library 를 사용하는 방법이 있다. 

하지만 각각의 장단점 및 제약 사항이 있기 때문에 혼용해서 사용하는 것이 가장 좋은 방법으로 생각된다.


pandas를 사용하면 조합하여 사용가능하다


Reading Excel Files

The read_excel() method can read Excel 2003 (.xls) and Excel 2007 (.xlsx) files using the xlrd Python module.


Writing Excel Files

Files with a .xls extension will be written using xlwt and

those with a .xlsx extension will be written using xlsxwriter (if available) or openpyxl.



-----------------------------------------------------------------------------------------------------

openpyxl https://openpyxl.readthedocs.org/


 read

write 

xls 

xlsx 

 O

Openpyxl is a Python library for reading and writing Excel 2010 xlsx/xlsm/xltx/xltm files.

It was born from lack of existing library to read/write natively from Python the Office Open XML format.



xlsxwriter https://xlsxwriter.readthedocs.org/

 read

write 

xls 

xlsx 

X

X

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.



xlrd - https://secure.simplistix.co.uk/svn/xlrd/trunk/xlrd/doc/xlrd.html?p=4966

 read

write 

xls 

xlsx 

 O

X

O

Development of this module would not have been possible without the document "OpenOffice.org's Documentation of the Microsoft Excel File Format" ("OOo docs" for short). The latest version is available from OpenOffice.org in PDF format and ODT format. Small portions of the OOo docs are reproduced in this document. A study of the OOo docs is recommended for those who wish a deeper understanding of the Excel file layout than the xlrd docs can provide.



xlwt https://xlwt.readthedocs.org/

 read

write 

xls 

xlsx 

X

xlwt is a library for writing data and formatting information to older Excel files (ie: .xls)xlwt is a library for writing data and formatting information to older Excel files (ie: .xls)


728x90