fix: Excel-Zellfarben beim Dokumentimport erhalten

This commit is contained in:
2026-07-23 15:44:58 +02:00
parent 8a2ccfd516
commit e4f4cd7c14
5 changed files with 169 additions and 16 deletions
+23 -1
View File
@@ -5,6 +5,7 @@ import sys
import pytest
from openpyxl import Workbook
from openpyxl.styles import PatternFill, Font
from openpyxl.worksheet.table import Table
@@ -39,10 +40,31 @@ def test_xlsx_imports_sheets_as_tables():
stream = BytesIO()
workbook.save(stream)
result = import_document(Upload(stream.getvalue(), "server.xlsx"))
assert "## Server" in result.markdown
assert "<h2>Server</h2>" in result.markdown
assert result.body_format == "html"
assert "web01" in result.markdown
def test_xlsx_preserves_cell_fill_and_font_colors_as_html():
workbook = Workbook()
sheet = workbook.active
sheet["A1"] = "Standort"
sheet["A1"].fill = PatternFill(fill_type="solid", fgColor="A5BF60")
sheet["A1"].font = Font(color="FFFFFF", bold=True)
sheet["A2"] = "Verwaltung"
sheet["A2"].fill = PatternFill(fill_type="solid", fgColor="EAF0DC")
stream = BytesIO()
workbook.save(stream)
result = import_document(Upload(stream.getvalue(), "farben.xlsx"))
assert result.body_format == "html"
assert "background-color: #a5bf60" in result.markdown
assert "color: #ffffff" in result.markdown
assert "font-weight: bold" in result.markdown
assert "background-color: #eaf0dc" in result.markdown
def test_rejects_legacy_excel():
with pytest.raises(ImportFailure, match="xlsx"):
import_document(Upload(b"", "legacy.xls"))