Heim >Backend-Entwicklung >PHP-Tutorial >Verwendung von Excel in Laravel5
http://www.maatwebsite.nl/laravel-excel/docs/getting-started
https://packagist.org/packages/maatwebsite/excel
Herunterladen
Komponisten aktualisieren
Oder konfigurieren Sie
<code>composer <span><strong>require</strong></span> maatwebsite/excel</code>
2 direkt in der Befehlszeile
app/config/app.php
Fügen Sie
zum Provider-Array hinzu
MaatwebsiteExcelExcelServiceProvider::class,
Zum Aliases-Array hinzufügen:
„Excel“ => MaatwebsiteExcelFacadesExcel::class,
3. Verwenden Sie
<code><span><span><?php</span><span>namespace</span><span>App</span>\<span>Http</span>\<span>Controllers</span>; <span>use</span><span>Illuminate</span>\<span>Http</span>\<span>Request</span>; <span>use</span><span>App</span>\<span>Http</span>\<span>Requests</span>; <span>use</span><span>App</span>\<span>Http</span>\<span>Controllers</span>\<span>Controller</span>; <span>use</span><span>Maatwebsite</span>\<span>Excel</span>\<span>Facades</span>\<span>Excel</span>; <span><span>class</span><span>DemoController</span><span>extends</span><span>Controller</span> {</span><span>public</span><span><span>function</span><span>getDemo</span><span>()</span>{</span><span>return</span> view(<span>"demo.demo"</span>); } <span>public</span><span><span>function</span><span>getExcel</span><span>()</span>{</span><span>// $excel = App::make('excel');</span> Excel::create(<span>'Laravel Excel'</span>, <span><span>function</span><span>(<span>$excel</span>)</span> {</span><span>$excel</span>->sheet(<span>'Excel sheet'</span>, <span><span>function</span><span>(<span>$sheet</span>)</span> {</span><span>$sheet</span>->setOrientation(<span>'landscape'</span>); }); })->export(<span>'xls'</span>); } } </span></span></code>
, um die Excel-API-Adresse
zu exportieren
http://www.maatwebsite.nl/laravel-excel/docs/export
Importieren Sie die Excel-API-Adresse
http://www.maatwebsite.nl/laravel-excel/docs/import
Das Obige stellt die Verwendung von Excel in Laravel5 vor, einschließlich der erforderlichen Inhalte. Ich hoffe, dass es für Freunde hilfreich ist, die sich für PHP-Tutorials interessieren.