{{ $doc->title }}
專案:{{ $doc->project->name }}
@if($doc->author) · 建立者:{{ $doc->author->name }} @endif
· 更新於 {{ $doc->updated_at->format('Y-m-d') }}
· 唯讀檢視
@if($isSheet)
@php
$sd = [];
try { $sd = json_decode(json_decode($doc->content), true) ?? []; } catch(\Exception $e) {}
try { if(empty($sd)) $sd = json_decode($doc->content, true) ?? []; } catch(\Exception $e) {}
/* Support both old single-sheet and new multi-sheet formats */
if (!empty($sd['sheets'])) {
$allSheets = array_values($sd['sheets']);
$activeIdx = (int)($sd['activeSheet'] ?? 0);
} else {
$allSheets = [['name' => 'Sheet1', 'rows' => $sd['rows'] ?? 0, 'cols' => $sd['cols'] ?? 0, 'data' => $sd['data'] ?? []]];
$activeIdx = 0;
}
$cl = function(int $n): string { $s=''; $n++; while($n>0){$s=chr(64+($n%26?:26)).$s; $n=intdiv($n-1,26);} return $s; };
$sheet = $allSheets[$activeIdx] ?? ($allSheets[0] ?? []);
$sRows = $sheet['rows'] ?? 0; $sCols = $sheet['cols'] ?? 0; $sData = $sheet['data'] ?? [];
@endphp
@if(count($allSheets) > 1)
@foreach($allSheets as $si => $sh)
{{ $sh['name'] ?? 'Sheet'.($si+1) }}
@endforeach
@endif
|
@for($c=0;$c<$sCols;$c++){{ $cl($c) }} | @endfor
@for($r=0;$r<$sRows;$r++)
| {{ $r+1 }} |
@for($c=0;$c<$sCols;$c++){{ $sData[$r][$c] ?? '' }} | @endfor
@endfor
@else
{!! $doc->content !!}
@endif