Install & Compatibility
Where this runs
tested against v1.0.10 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.068s · 17.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.062s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
open_workbook
✓ from pyxlsb import open_workbook
Demonstrates how to open an .xlsb file, access its first sheet, and iterate through rows to print cell values. Note that `pyxlsb` is a read-only library, so you'll need an existing `.xlsb` file (e.g., 'example.xlsb') for the code to execute successfully.
import os
from pyxlsb import open_workbook
# Create a dummy .xlsb file for demonstration if it doesn't exist
# In a real scenario, you would have your existing file.
# Note: pyxlsb can only read, not write .xlsb files.
# A simple way to get one is to create an Excel file and save as 'Excel Binary Workbook (*.xlsb)'
# For this example, let's assume 'example.xlsb' exists and has a sheet with data.
# If you don't have one, this example will likely fail or print nothing.
# For a real application, ensure 'example.xlsb' exists in the current directory
# or provide a full path.
file_path = os.path.join(os.getcwd(), 'example.xlsb') # Or provide an actual path
# You would typically have a real .xlsb file here.
# For a runnable example without manual file creation, this part is tricky as pyxlsb is read-only.
# For now, we assume a file named 'example.xlsb' exists.
try:
with open_workbook(file_path) as wb:
# Access the first sheet by index (1-based)
# Or by name: with wb.get_sheet('Sheet1') as sheet:
with wb.get_sheet(1) as sheet:
print(f"Reading sheet: {sheet.name}")
# Iterate through rows
for row_index, row in enumerate(sheet.rows()):
if row_index >= 5: # Limit output for quickstart
break
row_values = [cell.v for cell in row if cell.v is not None]
if row_values:
print(f"Row {row_index + 1}: {row_values}")
except FileNotFoundError:
print(f"Warning: '{file_path}' not found. Please create an example.xlsb file to run this quickstart.")
except Exception as e:
print(f"An error occurred: {e}")
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyxlsb'
The `pyxlsb` library is not installed in the current Python environment.
zipfile.BadZipFile: File is not a zip file
The provided file is either corrupted, not a valid .xlsb file, or has an invalid ZIP structure.
fixVerify the file is a legitimate and uncorrupted .xlsb file. Try opening it manually in Excel to confirm its integrity.
FileNotFoundError: [Errno 2] No such file or directory: 'your_file.xlsb'
The specified .xlsb file does not exist at the given path or the path is incorrect.
fixDouble-check the file path and name, ensuring it is correct and the file exists at that location.
KeyError: 'Sheet1'
The specified sheet name does not exist in the .xlsb workbook or there is a mismatch in case/spelling.
fixUse `workbook.sheets` to list all available sheet names and ensure the provided name matches exactly (case-sensitive).
Upgrade
Version history
1.0.10latest on PyPI · released Oct 14, 2022
Audit
Dependencies
No dependency data recorded yet.