当前位置:Gxlcms > PHP教程 > laravel5中使用excel

laravel5中使用excel

时间:2021-07-01 10:21:17 帮助过:14人阅读

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

下载

laravel5 中使用excel
更新composer
或者直接在命令行中

composer require maatwebsite/excel

2配置

app/config/app.php
providers数组中添加
Maatwebsite\Excel\ExcelServiceProvider::class,
aliasses数组中添加:
‘Excel’ => Maatwebsite\Excel\Facades\Excel::class,

3、使用

namespaceApp\Http\Controllers;

useIlluminate\Http\Request;

useApp\Http\Requests;
useApp\Http\Controllers\Controller;
useMaatwebsite\Excel\Facades\Excel;

classDemoControllerextendsController
{publicfunctiongetDemo(){return view("demo.demo");

    }
    publicfunctiongetExcel(){// $excel = App::make('excel');
        Excel::create('Laravel Excel', function($excel) {$excel->sheet('Excel sheet', function($sheet) {$sheet->setOrientation('landscape');

            });

        })->export('xls');
    }
}

导出excel api地址
http://www.maatwebsite.nl/laravel-excel/docs/export
导入excel api地址
http://www.maatwebsite.nl/laravel-excel/docs/import

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

    以上就介绍了laravel5 中使用excel,包括了require方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

  • 人气教程排行