Feuille vide
" n_cols = max(len(row) for row in grid) out = [ ( '| ' ) ] out += [f" | {get_column_letter(c)} | " for c in range(1, n_cols + 1)] out.append("
|---|---|
| {r} | ') for c, val in enumerate(row, start=1): ref = f"{get_column_letter(c)}{r}" meta = (styles or {}).get(ref) if meta is None: style_attr = "" else: # Legacy callers may still pass a bare CSS string. if isinstance(meta, str): meta = {"style": meta} fragment = meta.get("style", "") align = meta.get("align") if align and align not in ("left",): # left is the table default; only non-default alignments # need an explicit declaration. fragment = f"{fragment};text-align:{align}" if fragment else f"text-align:{align}" style_attr = f' style="{fragment}"' if fragment else "" # The cached result only makes sense for a formula cell: on a plain # value cell the two reads are identical and showing both would # duplicate the text. shadow = "" if cached is not None and val.startswith("="): # `c` is 1-based (A1 notation) and `r` too, while the grid is # 0-based: translate both. cval = _cell_cached(cached, r - 1, c - 1) if cval and cval != val: # The tooltip is translated client-side from # `xlsx.cached_value_title`; never hardcode UI text here. shadow = ( f'' f"{html.escape(cval)}" ) out.append( f'{html.escape(val)}{shadow} | ' ) out.append("
Feuille vide
" n_cols = max(len(r) for r in rows) out = [ ('| ') ] out += [f" | {get_column_letter(c)} | " for c in range(1, n_cols + 1)] out.append("
|---|---|
| {r} | ') for c in range(1, n_cols + 1): val = row[c - 1] if c - 1 < len(row) else "" out.append(f'{html.escape(val)} | ') out.append("
Feuille vide
' ), "rows": 0, "cols": 0, "total_rows": 0, "total_cols": 0, "max_rows": MAX_ROWS, "max_cols": MAX_COLS, "truncated": False, "styles": {}, "aligns": {}, "merges": [], "freeze": "", } ] sheets: list[dict[str, Any]] = [] for i, title in enumerate(titles): grid = grids[i] if i < len(grids) else [] t_rows, t_cols = total[i] if i < len(total) else (0, 0) sheets.append( { "name": title, "html": _table(grid), "rows": len(grid), "cols": max((len(r) for r in grid), default=0), "total_rows": t_rows, "total_cols": t_cols, "max_rows": MAX_ROWS, "max_cols": MAX_COLS, "truncated": t_rows > MAX_ROWS or t_cols > MAX_COLS, "styles": {}, "aligns": {}, "merges": [], "freeze": "", } ) return sheets