{"id":9416,"library":"xlsx2html","title":"XLSX to HTML Converter","description":"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.","status":"active","version":"0.6.4","language":"en","source_language":"en","source_url":"https://github.com/Apkawa/xlsx2html","tags":["xlsx","excel","html","converter","spreadsheet","formatting","openpyxl"],"install":[{"cmd":"pip install xlsx2html","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used for parsing XLSX files and handling image exports.","package":"openpyxl","optional":false},{"reason":"Used for handling rich text strings, which openpyxl does not fully support.","package":"rubyXL","optional":false}],"imports":[{"symbol":"xlsx2html","correct":"from xlsx2html import xlsx2html"}],"quickstart":{"code":"import io\nfrom xlsx2html import xlsx2html\n\n# Create a dummy XLSX file for demonstration\n# (In a real scenario, you would have an actual .xlsx file)\n# For this example, let's assume 'example.xlsx' exists.\n# You can create one manually or with openpyxl.\n# Example: workbook = openpyxl.Workbook(); workbook.active['A1'] = 'Hello'; workbook.save('example.xlsx')\n\n# Option 1: Convert an XLSX file path to an HTML file path\n# xlsx2html('path/to/example.xlsx', 'path/to/output.html')\n\n# Option 2: Convert an XLSX file-like object to an HTML string (in-memory)\nwith open('example.xlsx', 'rb') as xlsx_file:\n    output_stream = io.StringIO()\n    xlsx2html(xlsx_file, output_stream, locale='en')\n    output_stream.seek(0)\n    html_content = output_stream.read()\n    print(html_content[:500]) # Print first 500 chars of HTML for brevity","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your Python environment to 3.7 or higher.","message":"Support 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.","severity":"breaking","affected_versions":">=0.4.2"},{"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`.","message":"Prior 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.","severity":"gotcha","affected_versions":"<0.6.0"},{"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.","message":"Specific 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Open your XLSX file-like objects with `'rb'` mode: `xlsx_file = open('path/to/example.xlsx', 'rb')`.","message":"When 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Upgrade `xlsx2html` to version 0.5.0 or newer: `pip install --upgrade xlsx2html`.","cause":"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.","error":"TypeError: Cell object is not iterable"},{"fix":"Upgrade `xlsx2html` to version 0.6.1 or newer: `pip install --upgrade xlsx2html`. This version includes a fix for `UnicodeEncodeError`.","cause":"This issue was related to `xlsx2html`'s handling of non-unicode system locales, leading to encoding failures for certain characters.","error":"UnicodeEncodeError: 'charmap' codec can't encode character..."},{"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.","cause":"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.","error":"The output HTML only contains data from the first sheet of my Excel file."}]}