Sivo 悉见

严格的空比较

匿名 · 更新于 2021/6/28

如果您希望您的0值是0Excel 工作表中的实际值而不是null(空单元格),您可以使用WithStrictNullComparison.

namespace App\Exports;

use Maatwebsite</span>Excel</span>Concerns</span>FromCollection; use Maatwebsite</span>Excel</span>Concerns</span>WithStrictNullComparison;

class InvoicesExport implements FromCollection, WithStrictNullComparison { public function __construct(InvoicesRepository $invoices) { $this->invoices = $invoices; }

<span class="token keyword" style="color: rgb(204, 153, 205); font-style: italic !important;">public</span> <span class="token keyword" style="color: rgb(204, 153, 205); font-style: italic !important;">function</span> <span class="token function" style="color: rgb(240, 141, 73);">collection</span><span class="token punctuation" style="color: rgb(204, 204, 204);">(</span><span class="token punctuation" style="color: rgb(204, 204, 204);">)</span>
<span class="token punctuation" style="color: rgb(204, 204, 204);">{</span>
    <span class="token keyword" style="color: rgb(204, 153, 205); font-style: italic !important;">return</span> <span class="token variable" style="color: rgb(126, 198, 153);">$this</span><span class="token operator" style="color: rgb(103, 205, 204);">-</span><span class="token operator" style="color: rgb(103, 205, 204);">&gt;</span><span class="token property" style="color: rgb(248, 197, 85); font-style: italic !important;">invoices</span><span class="token operator" style="color: rgb(103, 205, 204);">-</span><span class="token operator" style="color: rgb(103, 205, 204);">&gt;</span><span class="token function" style="color: rgb(240, 141, 73);">all</span><span class="token punctuation" style="color: rgb(204, 204, 204);">(</span><span class="token punctuation" style="color: rgb(204, 204, 204);">)</span><span class="token punctuation" style="color: rgb(204, 204, 204);">;</span>
<span class="token punctuation" style="color: rgb(204, 204, 204);">}</span>

}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

#