Open-Source Python XLS Editor Library
Free & Open Source Python library to create and edit Excel XLS files.
What is Pyexcel-XLS?
Pyexcel-XLS is an open-source Python library to create, open and modify Microsoft Excel XLS files. It is a sub-component of the Pyexcel library that has other components as well in addition to the Pyexcel-XLS. Pyexcel-XLS lets you work with the rows and columns of XLS file that you can edit and then save back the XLS file to disc. Pyexcel-XLS supports a number of Excel file formats for reading and writing with certain constraints.
Pyexcel-XLS Features
Following are some of the main features of Pyexcel-XLS API:
- One application programming interface(API) to handle multiple data sources such as physical file, memory file, SQLAlchemy table, Django Model, and Python data structures: dictionary, records and array.
- One API to read and write data in various excel file formats.
- For large data sets, data streaming are supported. A genenerator can be returned to you. Checkout iget_records, iget_array, isave_as and isave_book_as.
Supported File Formats
Pyexcel-XLS supports the following file formats.
File Format | Definition |
---|---|
csv | comma separated values |
tsv | tab separated values |
csvz | a zip file that contains one or many csv files |
tsvz | a zip file that contains one or many tsv files |
xls | a spreadsheet file format created by MS-Excel 97-2003 |
xlsx | MS-Excel Extensions to the Office Open XML SpreadsheetML File Format. |
xlsm | an MS-Excel Macro-Enabled Workbook file |
ods | open document spreadsheet |
fods | flat open document spreadsheet |
json | java script object notation |
html | html table of the data structure |
simple | simple presentation |
rst | rStructured Text presentation of the data |
mediawiki | media wiki table |
Pyexcel API Overview
Getting Started with Pyexcel-XLS
We can download the Pyexcel-XLS library from GitHub or using pip install command:
Installation
Installing Pyexcel-XLS is simple and can be done from terminal as shown below:
Installing Pyexcel-XLS
pip3 install Pyexcel-XLS
Pyexcel-XLS Python Code Examples
Examples using the Pyexcel-XLS Python library are as follow. You can use the FREE Excel XLS file template to try these examples.Read and Save XLS file in Python
You can read an XLS file using the Pyexcel-XLS Python library and then save it back to disc using the save_as commadn of the API as shown in the folloiwng code sample.
Add a Row to Excel XLS using Python
Pyexcel-XLS allows you to add a row to the Excel XLS file using the get_sheet method on the Workbook class of the API. This adds a row next to the existing maximum row count of the XLS file as shown in the following code exmaple.
Add a Column to Excel XLS with Pyexcel-XLS
Just as you can add a row to an Excel XLS using Pyexcel-XLS API, you can add a column to the XLS file using the API. This is as shown in the following code sample.
Update Column Data in XLS file in Python
In addition to adding new column to an XLS file, you can also update the contents of an existing column using the Pyexcel-XLS API. This is done by accessing the column by its index and putting the data in this specific column.
Resources
Conclusion
Pyexcel-XLS API lets you work with XLS files from within your Python applications. It lets you read, edit and save back the modified XLS file using Python. Use the free template excel file above
Similar Products
- Apache POI XWPF | Open Source Java API to Create & Modify DOCX files
- DocX | Open Source .NET API to Create & Modify DOCX files
- Docx4J | Java API to Create & Modify DOC and DOCX files
- ExcelDataReader | Open Source .NET API to read XLS, XLSX, CSV and Spreadsheet documents
- FileFormat.Cells | Cerate and Update Excel files with C# .NET