我正在尝试向加载了 phpspreadsheet html 阅读器的 xlsx 文件添加注释。
这是由 PhpOffice\PhpSpreadsheet\Reader\Html
导入的 html。
<table>
<thead>
<tr>
@foreach($headings as $heading)
<th>{{$heading}}</th>
@endforeach
</tr>
</thead>
<tbody>
@foreach($failures as $rowKey => $failure)
<tr>
@foreach($failure as $key => $value)
@php
$style = '';
$comment = '';
if (isset($failingAttributes[$rowKey])) {
if ($failingAttributes[$rowKey]->contains($key)) {
$style = 'background-color:#FC4140;';
$comment = $failuresMessages[$rowKey][$key];
}
}
@endphp
<td style="{{$style}}">
@if($comment) <span style="visibility:hidden" class="comment">{{$comment}}</span> @endif
{{ $value }}
</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>
当注释正确添加到单元格时,它也会在单元格内写入值。
我想要的只是将
$value
写入单元格,同时保留注释:
我尝试添加 style="visibility:hidden"
和 style="display:none"
,但它忽略了它,结果与我的第一个屏幕截图相同。
是否可以在不将其添加到单元格值之前进行评论?