fix: Farben freier Excel-Zellen beim Glätten bewahren

This commit is contained in:
2026-07-23 16:13:38 +02:00
parent 4690e67b32
commit dbf3e7a62a
4 changed files with 27 additions and 4 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ class DocumentationConfig(PluginConfig):
name = "netbox_documentation"
verbose_name = "NetBox Dokumentation"
description = "Wiki und Office-Dokumentation direkt in NetBox"
version = "0.7.9"
version = "0.7.10"
author = "LKE"
base_url = "documentation"
min_version = "4.0.0"
+7 -2
View File
@@ -382,9 +382,14 @@ def _render_flattened_worksheet(sheet, workbook, max_rows=None):
tables_starting_here.append(bounds)
rendered_tables.add(bounds)
continue
value = sheet.cell(row=row_number, column=column_number).value
cell = sheet.cell(row=row_number, column=column_number)
value = cell.value
if value not in (None, ""):
ordinary_values.append(escape(str(value)).replace("\n", "<br>"))
rendered_value = escape(str(value)).replace("\n", "<br>")
style = _excel_cell_style(cell, workbook) if cell.has_style else ""
if style:
rendered_value = f'<span style="{style}">{rendered_value}</span>'
ordinary_values.append(rendered_value)
if ordinary_values:
blocks.append("<p>" + "<br>".join(ordinary_values) + "</p>")
for min_col, min_row, max_col, max_row in tables_starting_here:
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "netbox-documentation"
version = "0.7.9"
version = "0.7.10"
description = "Integrated Markdown wiki and office document importer for NetBox"
readme = "README.md"
requires-python = ">=3.10"
+18
View File
@@ -231,3 +231,21 @@ def test_excel_flatten_preserves_colors_of_explicit_excel_tables():
assert results[0].body_format == "html"
assert results[0].markdown.count("background-color: #a5bf60") == 2
assert results[0].markdown.count("color: #ffffff") == 2
def test_excel_flatten_preserves_colored_cells_outside_tables():
workbook = Workbook()
sheet = workbook.active
sheet["A1"] = "Wichtiger Hinweis"
sheet["A1"].fill = PatternFill(fill_type="solid", fgColor="FFF3BF")
sheet["A1"].font = Font(color="9C2A2A", bold=True)
sheet["A3"] = "Normaler Text"
stream = BytesIO()
workbook.save(stream)
results = import_excel_sheets(Upload(stream.getvalue(), "hinweis.xlsx"), flatten=True)
assert results[0].body_format == "html"
assert '<span style="background-color: #fff3bf; color: #9c2a2a; font-weight: bold' in results[0].markdown
assert "Wichtiger Hinweis</span>" in results[0].markdown
assert "<table" not in results[0].markdown