Registry / data / excelrd

excelrd

JSON →
library3.0.0pypypi✓ verified 86d ago

excelrd is a Python library designed for developers to extract data and formatting information from Microsoft Excel spreadsheet files, supporting both the older `.xls` and newer `.xlsx` formats. It is a modified version of the `xlrd` library, specifically updated to maintain compatibility and functionality with modern Python versions (3.7+), as `xlrd` itself no longer supports `.xlsx` files in its recent versions. The library is currently at version 3.0.0 and sees releases primarily for Python compatibility and maintenance.

pip install excelrd
INSTALL
IMPORT
SIG · EXCELRD
E
excelrd
datapythonv3.0.0
Install
1.6s avg
Import
70ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.072s · 18.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.6s · import 0.068s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

excelrd
import excelrd
open_workbook
import excelrd book = excelrd.open_workbook("filename.xls")

The quickstart demonstrates how to open an Excel workbook, retrieve the number of sheets and their names, access a specific sheet by its index, and then iterate through its cells to print their values. This pattern is fundamental for extracting tabular data.

import excelrd import os # Create a dummy Excel file for demonstration (replace with your actual file) excel_file_path = "namesdemo.xls" # In a real scenario, you'd have an existing .xls or .xlsx file. # For a runnable example, we'll simulate opening one. # Assuming 'namesdemo.xls' exists with at least 3 sheets. # In a real app, ensure the file exists. # Example of opening and reading data from an Excel file try: book = excelrd.open_workbook(excel_file_path) print(f"The number of worksheets is {book.nsheets}") print(f"Worksheet name(s): {', '.join(book.sheet_names())}") # Access a specific sheet by index (e.g., the first sheet) sh = book.sheet_by_index(0) print(f"{sh.name}: rows={sh.nrows}, cols={sh.ncols}") # Iterate through rows and print cell values for row_idx in range(sh.nrows): for col_idx in range(sh.ncols): cell = sh.cell(row_idx, col_idx) if cell.value is not None and str(cell.value).strip(): # Check for non-empty cells print(f"row={row_idx}, col={col_idx}, value={cell.value}") except FileNotFoundError: print(f"Error: Excel file '{excel_file_path}' not found. Please create it or provide a valid path.") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
breakingVersion 3.0.0 dropped support for Python 3.5 and 3.6. Ensure your environment uses Python 3.7 or newer for compatibility.
fix
Upgrade your Python interpreter to version 3.7 or higher. If you must use older Python versions, consider pinning `excelrd<3.0.0` (though this is not recommended due to lack of security updates).
affects: 3.0.0+
breakingVersion 2.0.0 dropped support for Python 2. This was a significant change moving the library to Python 3 exclusivity.
fix
Migrate your codebase to Python 3. `excelrd` versions 2.0.0 and later are Python 3 only.
affects: 2.0.0+
gotchaexcelrd (like its base xlrd) extracts only the *results* of formulas, not the formulas themselves. If a cell contains a formula, you will get the calculated value, not the formula string (e.g., `=A1+B1`).
fix
If you need to extract the formulas, `excelrd` is not the right tool. Consider `openpyxl` (for .xlsx) or other libraries designed for formula extraction.
affects: All versions
gotchaPassword-protected (encrypted) Excel files are not supported and cannot be read by `excelrd`.
fix
Ensure that any Excel files you intend to process with `excelrd` are not password-protected. Remove password protection manually before attempting to read them programmatically.
affects: All versions
gotchaThe library will ignore various embedded objects and features such as charts, macros, pictures, comments, hyperlinks, autofilters, advanced filters, pivot tables, conditional formatting, and data validation. Only the raw data content is extracted.
fix
Be aware of this limitation when expecting to preserve or extract non-data elements. If these elements are critical, an alternative library or tool might be necessary.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'excelrd'
The `excelrd` library has not been installed in your Python environment or the environment where the script is being run is not the one where `excelrd` was installed.
fix
Run `pip install excelrd` to install the library.
FileNotFoundError: [Errno 2] No such file or directory: 'your_excel_file.xls'
The specified Excel file path is incorrect, the file does not exist at the given location, or the program does not have read permissions for the file or directory.
fix
Double-check the file path and name, ensuring it's absolute or correctly relative to your script's execution directory. Verify file permissions.
excelrd.XLRDError: Unsupported format, or corrupt file: Expected BOF record; found 0x...
This error typically indicates that the file being opened is not a valid Excel file or is corrupted. While `excelrd` is designed to handle both `.xls` and `.xlsx` files, it relies on underlying format recognition, which can fail for malformed or non-standard Excel files.
fix
Verify that the file you are attempting to open is a legitimate Excel file and not, for example, a CSV file renamed to .xls, or a severely corrupted document. Try opening the file manually in Excel to confirm its integrity. If it's an `.xlsx` file and you are certain it's valid, ensure `excelrd` is updated to the latest version to handle newer `.xlsx` structures.
Upgrade
Version history
3.0.0latest on PyPI · released Jul 8, 2023
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
14
Resources
excelrd — pip install excelrd · libregistry