Registry / data / xlsx2html

xlsx2html

JSON →
library0.6.4pypypi✓ verified 86d ago

xlsx2html is a Python library designed for converting Excel (XLSX) files into HTML tables while striving to preserve cell formatting. It is actively maintained, with ongoing updates to support newer Python versions, address bugs, and introduce new features for more flexible conversions. The current stable version is 0.6.4.

pip install xlsx2html
INSTALL
IMPORT
SIG · XLSX2HTML
X
xlsx2html
datapythonv0.6.4
Install
2.5s avg
Import
432ms
Disk
53MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.4 · 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.910 runs
installs and imports cleanly · install 0.0s · import 0.457s · 54.5MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.5s · import 0.407s · 55MB
53MB installed
● package 53MB
Code
Verified usage

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

xlsx2html
from xlsx2html import xlsx2html

This quickstart demonstrates how to convert an XLSX file to HTML. It shows both direct file-to-file conversion and in-memory conversion using file-like objects. Remember to replace 'example.xlsx' with your actual file.

import io from xlsx2html import xlsx2html # Create a dummy XLSX file for demonstration # (In a real scenario, you would have an actual .xlsx file) # For this example, let's assume 'example.xlsx' exists. # You can create one manually or with openpyxl. # Example: workbook = openpyxl.Workbook(); workbook.active['A1'] = 'Hello'; workbook.save('example.xlsx') # Option 1: Convert an XLSX file path to an HTML file path # xlsx2html('path/to/example.xlsx', 'path/to/output.html') # Option 2: Convert an XLSX file-like object to an HTML string (in-memory) with open('example.xlsx', 'rb') as xlsx_file: output_stream = io.StringIO() xlsx2html(xlsx_file, output_stream, locale='en') output_stream.seek(0) html_content = output_stream.read() print(html_content[:500]) # Print first 500 chars of HTML for brevity
xlsx2html --version
Debug
Known issues
breakingSupport for Python 3.6 was dropped in version 0.4.2. Users on Python 3.6 must upgrade their Python environment to 3.7 or newer to use `xlsx2html` versions 0.4.2 and beyond.
fix
Upgrade your Python environment to 3.7 or higher.
affects: >=0.4.2
gotchaPrior to version 0.6.0, `xlsx2html` would only process the first sheet of an Excel workbook by default. Multi-sheet conversion required specific manual iteration.
fix
For v0.6.0 and later, use `xlsx2html(sheet=-1)` to render all sheets, or pass a list of sheet indices/names (e.g., `sheet=[0, 'Sheet2']`) to select specific sheets. For older versions, manually iterate through sheets using an underlying library like `openpyxl`.
affects: <0.6.0
gotchaSpecific Excel formatting, such as complex borders on empty cells, merged cells, or certain number formats (e.g., currency symbols), may not be perfectly preserved in the generated HTML due to inherent differences between Excel rendering and HTML/CSS capabilities. This can also lead to issues where empty cells appear without borders.
fix
Ensure you are using the latest version of `xlsx2html` as improvements are continuously made. For persistent issues, simplify Excel formatting or consider custom post-processing of the generated HTML. Check the GitHub issues for known limitations or workarounds.
affects: All versions
gotchaWhen using file-like objects (e.g., `io.BytesIO`, `io.StringIO`) for input, the XLSX file must be opened in binary mode (`'rb'`). Using text mode (`'r'`) will lead to errors.
fix
Open your XLSX file-like objects with `'rb'` mode: `xlsx_file = open('path/to/example.xlsx', 'rb')`.
affects: All versions
Errors
Common errors & fixes
TypeError: Cell object is not iterable
This error often occurred in versions prior to 0.5.0, particularly when dealing with merged cells or complex cell structures in the XLSX input.
fix
Upgrade `xlsx2html` to version 0.5.0 or newer: `pip install --upgrade xlsx2html`.
UnicodeEncodeError: 'charmap' codec can't encode character...
This issue was related to `xlsx2html`'s handling of non-unicode system locales, leading to encoding failures for certain characters.
fix
Upgrade `xlsx2html` to version 0.6.1 or newer: `pip install --upgrade xlsx2html`. This version includes a fix for `UnicodeEncodeError`.
The output HTML only contains data from the first sheet of my Excel file.
Before version 0.6.0, the default behavior of `xlsx2html` was to process only the first sheet. Users had to implement custom logic to convert multiple sheets.
fix
If using `xlsx2html` 0.6.0 or newer, specify `sheet=-1` to convert all sheets (e.g., `xlsx2html(..., sheet=-1)`), or provide a list of sheet indices/names (e.g., `sheet=[0, 1]`). If using an older version, consider upgrading or implementing custom multi-sheet iteration.
Upgrade
Version history
0.6.4latest on PyPI · released Feb 23, 2026
Audit
Dependencies
openpyxlrequiredUsed for parsing XLSX files and handling image exports.
rubyXLrequiredUsed for handling rich text strings, which openpyxl does not fully support.
Agent activity
47 hits · last 30 days
node
42
OpenAI (training)
1
Resources
xlsx2html — pip install xlsx2html · libregistry