Home >Backend Development >PHP Tutorial >Using excel in laravel5

Using excel in laravel5

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 09:11:581271browse

http://www.maatwebsite.nl/laravel-excel/docs/getting-started
https://packagist.org/packages/maatwebsite/excel

Download

laravel5 中使用excel
Update composer
Or configure directly in the command line

<code>composer <span><strong>require</strong></span> maatwebsite/excel</code>

2

app/config/app.php
Add
to providers array MaatwebsiteExcelExcelServiceProvider::class,
Add to the aliases array:
‘Excel’ => MaatwebsiteExcelFacadesExcel::class,

3. Use

<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>

to export excel api address
http://www.maatwebsite.nl/laravel-excel/docs/export
Import excel api address
http://www.maatwebsite.nl/laravel-excel/docs/import

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the use of excel in laravel5, including the require content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn