PyExcel XLS

0.7.1 · active · verified Sat Apr 11

pyexcel-xls is a wrapper library designed to read, manipulate, and write data in the older Microsoft Excel XLS (Binary Interchange File Format) format. It functions primarily as a plugin for the `pyexcel` library, offering a unified API for spreadsheet data handling. The library is currently at version 0.7.1 and maintains an active, albeit sporadic, release cadence, typically tied to essential maintenance or updates of its core dependencies.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `pyexcel` (which leverages `pyexcel-xls` automatically) to write data to an `.xls` file and then read it back. It uses `OrderedDict` for structured sheet data and then saves and loads using `pyexcel.save_as` and `pyexcel.get_book` respectively.

import pyexcel
from collections import OrderedDict
import os

# Create some data
data = OrderedDict()
data.update({"Sheet 1": [[1, 2, 3], [4, 5, 6]]})
data.update({"Sheet 2": [["row 1", "row 2", "row 3"]]})

# Define a filename
file_name = "my_data.xls"

# Write data to an XLS file
pyexcel.save_as(dest_file_name=file_name, adict=data)
print(f"Data written to {file_name}")

# Read data from the XLS file
book = pyexcel.get_book(file_name=file_name)
for sheet in book:
    print(f"Sheet Name: {sheet.name}")
    for row in sheet:
        print(row)

# Clean up the created file
os.remove(file_name)
print(f"Cleaned up {file_name}")

view raw JSON →