Free Python Library to Read, Edit & Write XLS Files
A Small Size Open Source Python Library enables Software Developers to Read, Edit, Manipulate and Write Data in Excel XLS Spreadsheets via Python API.
Excel files are a ubiquitous part of business and data management helping users in dealing with financial reports, data analysis, or any other task that involves tabular data. Python, as one of the most popular programming languages for these tasks, provides a variety of libraries to work with different file formats. When it comes to working with Excel files in Python, the Pyexcel-XLS library is a valuable resource that simplifies the process of reading and writing Excel files.
Pyexcel-XLS is a Python library that is part of the larger pyexcel family, which provides a consistent interface to handle various spreadsheet formats, including Excel. This library allows users to read and write data from and to Excel files without the need for complex, low-level code. It offers a convenient and user-friendly approach to manipulate Excel files, making it suitable for tasks such as data extraction, reporting, and automation. There are several important features part of the library, such as writing data to an Excel file, reading existing Excel files, applying styles to cells and rows, merging cells, handling Excel formulas, working with Multiple Sheets and many more.
Pyexcel-XLS is a very easy to use and valuable Python library for working with Excel files. It simplifies the process of loading, reading and writing Excel data, making it an excellent choice for a wide range of data manipulation tasks. Whether you need to extract information from Excel files or generate reports, this library can streamline your workflow. So, if you find yourself frequently working with Excel files in Python, give it a try and experience the convenience it offers.
Getting Started with Pyexcel-XLS
The recommended way to install Pyexcel-XLS library is using pip. Please use the following command for a smooth installation.
Install Pyexcel-XLS via PIP Command
pip install Pyexcel-XLS
Install Pyexcel-XLS via GitHub
$ git clone https://github.com/pyexcel/pyexcel-xls.git
$ cd pyexcel-xls
$ python setup.py install
Writing to an Excel File using Python
The open source Pyexcel-XLS library has provided the capability for creating a simple Excel XLS file and writing data to it with just couple of lines of Python code inside their own applications. Software developers can also apply various types of formatting to it, load data from an external source, insert new rows and columns to it, merge cells both vertically and horizontally, and so on. In the following example, users create an Excel workbook, add data to it, name the columns based on the first row and extend the rows with our data using python code.
How to Create a Simple Excel XLS Spreadsheet using Python Library?
import pyexcel_xls
# Create a workbook
workbook = pyexcel_xls.get_sheet()
# Add data
data = [["Name", "Age", "City"],
["Alice", 25, "New York"],
["Bob", 30, "Los Angeles"]]
workbook.name_columns_by_row(0)
workbook.extend_rows(data)
# Save the workbook to an Excel file
workbook.save_as("output.xls")
Reading an Excel File via Python API
The Pyexcel-XLS library makes it easy for software developers to read Excel files inside their own applications without any external dependencies. The library enables Python developers to load and read an existing XLS files with just couple of lines of Python code. It also provide support for reading only a particular worksheet. Moreover, it is also possible to access and read a specific columns or row from a given excel file. The following shows how straightforward software developers can read data from an Excel file using Python code.
How to Read Data from Excel XLS Document using Python?
from pyexcel_xls import get_data
data = get_data("your_file.xls")
import json
print(json.dumps(data))
{"Sheet 1": [[1, 2, 3], [4, 5, 6]], "Sheet 2": [["row 1", "row 2", "row 3"]]}
Miscellaneous Features Support
The open source Pyexcel-XLS is a valuable Python library for working with Excel files. It simplifies the process of reading and writing Excel data, making it an excellent choice for a wide range of data manipulation tasks. There are several important features part of the library such as formatting cells, adding borders, setting cell colors to make your Excel files visually appealing, merging cells both vertically and horizontally, write and evaluate Excel formulas, create as well as manipulate multiple sheets within a single Excel file and so on.