Install & Compatibility
Where this runs
tested against v3.1.5.20260827 · 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.324s · 21.6MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.8s · import 0.304s · 22MB
20MB installed
● package 20MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Workbook
✓ from openpyxl import Workbook
types-openpyxl provides type hints for this import from the actual openpyxl library.
load_workbook
✓ from openpyxl import load_workbook
types-openpyxl provides type hints for this import from the actual openpyxl library.
Font
✓ from openpyxl.styles import Font
types-openpyxl provides type hints for style-related imports from the actual openpyxl library.
This quickstart demonstrates basic usage of `openpyxl`. When `types-openpyxl` is installed alongside `openpyxl`, static type checkers like MyPy or Pyright can use the provided stubs to perform type verification on this code.
import datetime
from openpyxl import Workbook
from openpyxl.styles import Font
def create_excel_with_types():
# This code uses openpyxl, and types-openpyxl provides type hints for it.
wb: Workbook = Workbook()
ws = wb.active
ws.title = "Typed Sheet"
# Type checking tools (like MyPy) will use types-openpyxl to validate these operations.
ws['A1'] = "Date"
ws['B1'] = "Value"
ws['A1'].font = Font(bold=True)
ws['B1'].font = Font(bold=True)
ws['A2'] = datetime.date(2026, 4, 9)
ws['B2'] = 123.45
file_path = "typed_sample.xlsx"
wb.save(file_path)
print(f"Excel file '{file_path}' created with type hints verified.")
if __name__ == "__main__":
create_excel_with_types()
Debug
Known issues
gotchaThis package provides *only* type stubs for `openpyxl`, not the `openpyxl` library itself. To use `openpyxl` with type hints, you must install both `openpyxl` and `types-openpyxl`.fixEnsure both `pip install openpyxl` and `pip install types-openpyxl` are run.
affects: All versions
gotchaType stubs are often tied to specific versions of the underlying library. While typeshed aims for broad compatibility, using `types-openpyxl` with an `openpyxl` version significantly different from the one it was generated for (e.g., `openpyxl==3.1.5` for `types-openpyxl 3.1.5.20260408`) may lead to incorrect type checking results.fixRefer to the `types-openpyxl` PyPI page or Typeshed documentation to find the `openpyxl` version the stubs are targeting. Ideally, keep `types-openpyxl` and `openpyxl` versions in sync, or at least close enough that their APIs don't diverge significantly.
affects: All versions
breakingChanges or bug fixes to `openpyxl`'s API (even minor ones) can lead to mismatches with the type stubs, causing type checkers to report errors on valid `openpyxl` code or fail to catch actual type errors. This is particularly relevant if `openpyxl` introduces new features or alters method signatures that are not yet reflected in the stubs.fixIf experiencing type checking issues after an `openpyxl` update, check if a newer `types-openpyxl` version is available. If not, consider reporting the discrepancy to the Typeshed project. Temporarily, you might need to use `type: ignore` comments if the code is known to be correct at runtime.
affects: Potentially any `types-openpyxl` version when `openpyxl` updates.
gotchaAll fixes and updates to the `openpyxl` type stubs should be contributed directly to the `python/typeshed` GitHub repository, not to the `types-openpyxl` PyPI package's maintainers directly. The PyPI package is automatically generated from Typeshed.fixTo contribute, submit pull requests to the `typeshed` repository's `stubs/openpyxl` directory.
affects: All versions
Upgrade
Version history
3.1.5.20260827latest on PyPI · released Aug 27, 2026
Audit
Dependencies
openpyxlrequiredThis package provides type stubs for openpyxl; openpyxl itself is a runtime dependency.
mypyoptionalA static type checker that utilizes these stubs.
pyrightoptionalA static type checker that utilizes these stubs.