This release is a pre-release and may not be stable for production use.
xx2html
xx2html converts Excel workbooks (.xlsx) into a single HTML file while preserving:
- Cell formatting and styles
- Conditional formatting classes (via
condif2css) - Worksheet link behavior
- Embedded worksheet images and in-cell rich-value images
Installation
pip install xx2html
Usage
from xx2html import apply_openpyxl_patches, create_xlsx_transform
# Explicit entrypoint. Patches are also applied automatically on import.
apply_openpyxl_patches()
transform = create_xlsx_transform(
sheet_html=(
'<section id="{enc_sheet_name}" data-sheet-name="{sheet_name}">'
"{table_generated_html}"
"</section>"
),
sheetname_html='<a class="sheet-nav" href="#{sheet_name}.A1">{sheet_name}</a>',
index_html=(
"<!doctype html><html><head>"
"{fonts_html}{core_css_html}{user_css_html}{generated_css_html}"
"{generated_incell_css_html}{conditional_css_html}"
"</head><body>{sheets_names_generated_html}{sheets_generated_html}"
"{safari_js}</body></html>"
),
fonts_html="",
core_css="",
user_css="",
safari_js="",
apply_cf=True,
)
ok, err = transform("input.xlsx", "output.html", "en_US")
if not ok:
raise RuntimeError(err)
API Map
Public API (xx2html):
apply_openpyxl_patches() -> None- Applies required openpyxl monkey patches (idempotent).
create_xlsx_transform(...) -> Callable[[str, str, str], tuple[bool, str | None]]- Returns a transformer callable with signature
(source_xlsx, dest_html, locale). - Returns
(True, None)on success,(False, "<error repr>")on failure.
- Returns a transformer callable with signature
Core helpers (xx2html.core, useful for advanced integrations):
get_worksheet_contents(...) -> WorksheetContentscova_render_table(worksheet_contents) -> strget_incell_images_refs(archive) -> tuple[dict[str, str], Exception | None]get_incell_css(...) -> strapply_cf_styles(html, cf_style_relations) -> strupdate_links(html, encoded_sheet_names, ...) -> str
Template Placeholders
sheet_html requires:
{enc_sheet_name}{sheet_name}{table_generated_html}
sheetname_html requires:
{enc_sheet_name}{sheet_name}
index_html requires:
{sheets_generated_html}{sheets_names_generated_html}{source_filename}{fonts_html}{core_css_html}{user_css_html}{generated_css_html}{generated_incell_css_html}{safari_js}{conditional_css_html}
Monkey Patching Behavior
xx2html relies on an openpyxl monkey patch to carry rich-value metadata used for in-cell images.
- The patch is applied automatically when
xx2html.coreis imported. - The explicit API entrypoint is
apply_openpyxl_patches().
Development
uv sync --group dev
python3 tests/scripts/generate_fixtures.py
python3 -m compileall src tests
python3 -m pytest
License
xx2html is dual-licensed under MIT or Apache-2.0.
Metadata
Release files for xx2html 0.15.0b6021700
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xx2html-0.15.0b6021700.tar.gz | 132.7 kB | Without provenance | Details for xx2html-0.15.0b6021700.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xx2html-0.15.0b6021700-py3-none-any.whl | Python 3 | none | any | Details for xx2html-0.15.0b6021700-py3-none-any.whl |
Total release size: 158.5 kB
Release files / xx2html-0.15.0b6021700.tar.gz
| Download URL | xx2html-0.15.0b6021700.tar.gz |
|---|---|
| Size | 132.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a04bd100d86ec1862332dd1d3d033d5f41a545952882cba642b6f340723cf56
|
|
BLAKE2b-256 checksum How to use checksums |
31fcf825ad16705f83036c014fa73bb00d7c47c5c1917781126ab49f12dc428c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.26.6 CPython/3.14.3 Darwin/24.6.0
|
Release files / xx2html-0.15.0b6021700-py3-none-any.whl
| Download URL | xx2html-0.15.0b6021700-py3-none-any.whl |
|---|---|
| Size | 25.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
52f683a7910c69fc615ff5bd77b688bea1aa6243e12ff71b49e794ad817c1fd3
|
|
BLAKE2b-256 checksum How to use checksums |
7c6b8c37030db2b17bb18f1892b1430db560f0f1f4740abf3d86f2e880e03af8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.26.6 CPython/3.14.3 Darwin/24.6.0
|
Security for xx2html 0.15.0b6021700
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.