Tablichka
Конвертер HTML в XLSX на BeautifulSoup и openpyxl. Нужен Python 3.14+.
BeautifulSoup читает HTML, BlockExtractor выделяет текст и таблицы в порядке
документа, GridBuilder рассчитывает координаты и объединения в SheetModel,
а ExcelWriter применяет стили и сохраняет файл.
Поддерживаются h1, p, таблицы с th/td, rowspan и colspan.
Размеры строк и столбцов подбираются приблизительно по тексту и шрифту.
CSS и JavaScript не обрабатываются.
Запуск
Из корня проекта:
uv sync
uv run tablichka input.html report.xlsx
Также работает uv run python -m tablichka input.html output.xlsx.
Команда использует базовое оформление. Пример со стилями и границами:
uv run python examples/convert_report.py
Использование как зависимости
В другом проекте добавь путь к этому репозиторию:
uv add /path/to/Tablichka
Без uv можно установить пакет через pip install /path/to/Tablichka.
После установки доступны импорт tablichka и одноимённая команда.
from tablichka import Style, convert, convert_file
from openpyxl.styles import Border, Font, Side
line = Side(style="thin", color="808080")
styles = {
"bordered": Style(border=Border(left=line, right=line, top=line, bottom=line)),
"header": Style(font=Font(name="Arial", size=12, bold=True)),
}
html = '<table><tr><th class="bordered header">Товар</th></tr></table>'
model = convert(html, "report.xlsx", styles=styles)
# Для файла: convert_file("input.html", "report.xlsx", styles=styles)
Классы применяются слева направо. Поле None сохраняет прежний параметр;
заданный Font, Border, PatternFill или Alignment заменяет компонент целиком.
Без заданных стилей используется DEFAULT_STYLE. Значения остаются строками,
пока класс явно не задаст content_type="number" или "date".
Стили задаются на самих текстовых блоках и ячейках, без наследования от обёрток.
Сборка и проверка
uv build
uv run python -m unittest discover -s tests -v
В dist/ появятся wheel и исходный архив. Wheel можно передать другому проекту:
pip install dist/tablichka-0.1.0-py3-none-any.whl
Metadata
Release files for tablichka 0.1.0
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 |
|---|---|---|---|---|
| tablichka-0.1.0.tar.gz | 6.5 kB | Without provenance | Details for tablichka-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tablichka-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for tablichka-0.1.0-py3-none-any.whl |
Total release size: 17.1 kB
Release files / tablichka-0.1.0.tar.gz
| Download URL | tablichka-0.1.0.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2afc07622b5245e78f02a1b1b79d38cc0f21ed3d6fc9db6e91b5853b7f423f22
|
|
BLAKE2b-256 checksum How to use checksums |
1b73a1f35c41f4853b1a79e4233063aaa7ca9257494a2b05ca9c87f513ef7e25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / tablichka-0.1.0-py3-none-any.whl
| Download URL | tablichka-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5fb3c19b2782a9803f5bc879d6f2cb82628646fb518d65ae9a6bffdca0b8edd7
|
|
BLAKE2b-256 checksum How to use checksums |
9ec5242d7d22f6199f3a9aa88ca0e534e52740aa857603a9bc85e0454d6b9dad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for tablichka 0.1.0
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.