mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-27 23:35:01 +00:00
51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
"""Monday.com-style branding for the Scenario Export workbook (ADR-0065).
|
|
|
|
A programmatic openpyxl styling pass (no template): a bold indigo header band
|
|
with white text, a frozen header row, subtle alternating row bands, and roomy
|
|
column widths. The palette lives here as the single home for brand colour — the
|
|
"no brand-colour constants anywhere" gap the review flagged.
|
|
|
|
TODO(brand): swap the placeholder Monday-style hex for the real Domna brand
|
|
palette once design supplies it.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from openpyxl.styles import Alignment, Font, PatternFill
|
|
from openpyxl.utils import get_column_letter
|
|
from openpyxl.worksheet.worksheet import Worksheet
|
|
|
|
# openpyxl colours are 8-char ARGB. Placeholder Monday-style palette.
|
|
HEADER_FILL: str = "FF6C6CFF" # indigo header band
|
|
HEADER_FONT: str = "FFFFFFFF" # white header text
|
|
ROW_BAND_FILL: str = "FFF1F1FF" # subtle alternating-row tint
|
|
|
|
_COLUMN_WIDTH: int = 18
|
|
|
|
|
|
def style_sheet(worksheet: Worksheet) -> None:
|
|
"""Paint the Monday-style branding onto a populated worksheet: header band +
|
|
font, frozen header row, banded rows, and column widths."""
|
|
header_fill = PatternFill(
|
|
start_color=HEADER_FILL, end_color=HEADER_FILL, fill_type="solid"
|
|
)
|
|
header_font = Font(bold=True, color=HEADER_FONT)
|
|
for cell in worksheet[1]:
|
|
cell.fill = header_fill
|
|
cell.font = header_font
|
|
cell.alignment = Alignment(horizontal="left", vertical="center")
|
|
|
|
# Keep the header visible while scrolling a long portfolio.
|
|
worksheet.freeze_panes = "A2"
|
|
|
|
band_fill = PatternFill(
|
|
start_color=ROW_BAND_FILL, end_color=ROW_BAND_FILL, fill_type="solid"
|
|
)
|
|
for row_index in range(3, worksheet.max_row + 1, 2):
|
|
for cell in worksheet[row_index]:
|
|
cell.fill = band_fill
|
|
|
|
for column_index in range(1, worksheet.max_column + 1):
|
|
worksheet.column_dimensions[get_column_letter(column_index)].width = (
|
|
_COLUMN_WIDTH
|
|
)
|