Files
AI_portal/dwg-counting/excel_export.py
Ondřej Glaser 48cef99257 Initial portal commit: landing + 9 AI-powered apps
Apps:
- dwg-rooms: extract room numbers from DWG/DXF
- dwg-counting: count symbols in PDF drawings (OpenCV template matching)
- contract-check: review PDF contracts against a checklist (Claude vision + Tesseract OCR fallback)
- email-drafter: bullet notes → polished Czech/English business emails
- invoice-extractor: PDF/image invoice → structured data → Excel
- translator: Czech-first translator across 19 languages with tone control
- vv-check: find inconsistent unit prices across VV sheets in one workbook
- vv-compare: diff original vs new VV files (changes / added / removed)
- feature-request: portal users submit ideas + sample files

Infrastructure:
- LiteLLM gateway with per-app virtual keys + budgets
- Langfuse observability
- Geist font, shared theme, cross-subdomain back link + theme sync via cookie/URL
- Caddy reverse proxy on *.klas.chat
2026-05-13 15:25:04 +02:00

42 lines
1.3 KiB
Python

"""Export symbol count results to XLSX."""
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Alignment
def export_to_excel(results: list[dict], filename: str, out_path: str) -> None:
"""results = [{id, description, count, confidence, notes}, ...]"""
wb = Workbook()
ws = wb.active
ws.title = "Symboly"
headers = ["Symbol", "Popis", "Počet", "Spolehlivost", "Poznámka"]
ws.append(headers)
for cell in ws[1]:
cell.font = Font(bold=True, color="FFFFFF")
cell.fill = PatternFill("solid", fgColor="2563EB")
cell.alignment = Alignment(horizontal="center")
for r in results:
ws.append([
r.get("id", ""),
r.get("description", ""),
r.get("count", 0),
r.get("confidence", ""),
r.get("notes", ""),
])
# Auto-width
widths = [16, 60, 10, 14, 40]
for i, w in enumerate(widths, 1):
ws.column_dimensions[chr(64 + i)].width = w
# Total row
total = sum(int(r.get("count", 0) or 0) for r in results)
ws.append([])
last = ws.max_row + 1
ws.append(["", f"Celkem ({filename})", total, "", ""])
ws[f"B{last+1}"].font = Font(bold=True)
ws[f"C{last+1}"].font = Font(bold=True)
wb.save(out_path)