fix: resolve audit report gaps across bulk imports, auth, scoping, and exports
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import csv
|
||||
from io import BytesIO, StringIO
|
||||
import re
|
||||
from typing import Any
|
||||
from openpyxl import Workbook
|
||||
from openpyxl.styles import Alignment, Border, Font, PatternFill, Side
|
||||
@@ -8,6 +9,12 @@ from openpyxl.utils import get_column_letter
|
||||
from ..core.time_utils import format_datetime, utc_now
|
||||
|
||||
|
||||
def _sanitize_sheet_title(title: str) -> str:
|
||||
"""Sanitize Excel sheet title to comply with openpyxl / Excel naming rules."""
|
||||
cleaned = re.sub(r'[\\/*?:\[\]]', '_', title or "Report").strip()
|
||||
return cleaned[:31] or "Report"
|
||||
|
||||
|
||||
def _format_filters_echo(filters_applied: dict[str, Any]) -> str:
|
||||
if not filters_applied:
|
||||
return "None"
|
||||
@@ -86,7 +93,7 @@ def _detect_cell_format(col_key: str, col_label: str, val: Any) -> tuple[Alignme
|
||||
def build_xlsx(report_payload: dict[str, Any]) -> BytesIO:
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = report_payload["title"][:31]
|
||||
ws.title = _sanitize_sheet_title(report_payload.get("title", "Report"))
|
||||
|
||||
# Explicitly show grid lines in Excel view
|
||||
ws.views.sheetView[0].showGridLines = True
|
||||
|
||||
Reference in New Issue
Block a user