dcat-admin

dcat-admin


自定义导出

<h1>自定义导出</h1> <p>dcat-admin的数据表格默认支持导出csv文件,</p> <pre><code class="language-php">&amp;lt;?php namespace App\Admin\Extensions; use Dcat\Admin\Grid\Exporters\AbstractExporter; class CustomExporter extends AbstractExporter { public function export() { $filename = $this-&amp;gt;getTable().'.csv'; $data = $this-&amp;gt;getData(); $output = ''; $headers = [ 'Content-Encoding' =&amp;gt; 'UTF-8', 'Content-Type' =&amp;gt; 'text/csv;charset=UTF-8', 'Content-Disposition' =&amp;gt; &amp;quot;attachment; filename=\&amp;quot;$filename\&amp;quot;&amp;quot;, ]; response(rtrim($output, &amp;quot;\n&amp;quot;), 200, $headers)-&amp;gt;send(); exit; } }</code></pre>

页面列表

ITEM_HTML