{{ $isSheet ? 'πŸ“Š' : 'πŸ“„' }}

{{ $doc->title }}

專摈:{{ $project->name }}   εŒ―ε‡Ίζ™‚ι–“οΌš{{ now()->format('Y-m-d H:i') }}   @if($doc->author) ε»Ίη«‹θ€…οΌš{{ $doc->author->name }} @endif
@if($isSheet) @php // Robust sheet JSON decoder (handles single or legacy double-encoded content) $raw = $doc->content ?? ''; $decoded = json_decode($raw, true); if (is_string($decoded)) { $decoded = json_decode($decoded, true); } $sheetData = is_array($decoded) ? $decoded : []; /* Support both old single-sheet and new multi-sheet formats */ if (!empty($sheetData['sheets'])) { $activeIdx = (int)($sheetData['activeSheet'] ?? 0); $activeSheet = $sheetData['sheets'][$activeIdx] ?? ($sheetData['sheets'][0] ?? []); $rows = $activeSheet['rows'] ?? 0; $cols = $activeSheet['cols'] ?? 0; $data = $activeSheet['data'] ?? []; } else { $rows = $sheetData['rows'] ?? 0; $cols = $sheetData['cols'] ?? 0; $data = $sheetData['data'] ?? []; } $colLabel = function(int $n): string { $s = ''; $n++; while ($n > 0) { $s = chr(64 + ($n % 26 ?: 26)) . $s; $n = intdiv($n - 1, 26); } return $s; }; // Extract display value: plain string, or array {v, _r, b, ...} $cellDisplay = function ($cell): string { if (is_array($cell)) { $v = array_key_exists('_r', $cell) ? $cell['_r'] : ($cell['v'] ?? ''); return is_numeric($v) ? rtrim(rtrim(number_format((float)$v, 10, '.', ''), '0'), '.') : (string)$v; } return (string)($cell ?? ''); }; $cellStyle = function ($cell): string { if (!is_array($cell)) return ''; $s = ''; if (!empty($cell['b'])) $s .= 'font-weight:bold;'; if (!empty($cell['i'])) $s .= 'font-style:italic;'; if (!empty($cell['u'])) $s .= 'text-decoration:underline;'; if (!empty($cell['c'])) $s .= 'color:' . htmlspecialchars($cell['c']) . ';'; if (!empty($cell['bg'])) $s .= 'background:' . htmlspecialchars($cell['bg']) . ';'; if (!empty($cell['a'])) $s .= 'text-align:' . htmlspecialchars($cell['a']) . ';'; return $s; }; @endphp @for($c=0;$c<$cols;$c++)@endfor @for($r=0;$r<$rows;$r++) @for($c=0;$c<$cols;$c++) @php $cell = $data[$r][$c] ?? null; @endphp @endfor @endfor
{{ $colLabel($c) }}
{{ $r+1 }}{{ $cellDisplay($cell) }}
@else {!! $doc->content !!} @endif