- Converts Excel files (.xlsx, .xls) to HTML
- Preserves merged cells with
rowspanandcolspanattributes - Handles hidden rows and columns correctly
- Generates standalone HTML files with minimal styling
Install from PyPI:
pip install xl2htmOr with uv:
uv pip install xl2htmoptions:
excel_file: Path to the Excel file (.xlsx or .xls)-s, --sheets: List of sheet names to convert (if not specified, all sheets are converted)
for exmaple:
xl2htm spreadsheet.xlsx -s Sheet1 Sheet2 > output.htmlImport and use in Python:
from xl2htm import excel_to_html
# Convert all sheets to HTML
html = excel_to_html('spreadsheet.xlsx')
print(html)Convert specific sheets:
from xl2htm import excel_to_html
html = excel_to_html('spreadsheet.xlsx', sheet_names=['Sheet1', 'Sheet2'])
print(html)Get individual sheet objects:
from xl2htm import extract_sheets, extract_sheet
# Extract all sheets
sheets = extract_sheets('spreadsheet.xlsx')
for sheet in sheets:
print(f"Sheet: {sheet.name}")
print(f"Rows: {sheet.rows_count()}, Columns: {sheet.columns_count()}")
# Extract a single sheet by name
sheet = extract_sheet('spreadsheet.xlsx', 'Sheet1')
html_table = sheet.table()MIT