{{ $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++){{ $colLabel($c) }} | @endfor
@for($r=0;$r<$rows;$r++)
| {{ $r+1 }} |
@for($c=0;$c<$cols;$c++)
@php $cell = $data[$r][$c] ?? null; @endphp
{{ $cellDisplay($cell) }} |
@endfor
@endfor
@else
{!! $doc->content !!}
@endif