文章采集与网上
方式1。使用原生的phpexcel ,
http://blog.csdn.net/CSwfe/article/details/52748046?locationNum=1
1、在app目录下创建一个新的文件夹,命名libs(可自定义) app/libs/phpExcel
2、(可选)考虑到后面可能会引用很多库,so,在libs下再创建一个phpExcel文件夹,把phpExcel类放入此文件夹下。
3、找到根目录下的composer.json文件
4、找到composer.json中定义的(看我备注)
//加入phpExcel类的路径
5、安装composer,windows下可以在百度上下载
6、运行命令行进入项目根目录,执行“composer dumpautoload”,
7、在控制器中use PHPExcel
8、在方法中实例化phpExccel对象,打印该对象看phpExcel类是否引入成功。
$objPHPExcel = new PHPExcel();
print_r($objPHPExcel);
==========以上是引入phpExcel类步骤(其它第三方类与此类似)============
<span style="font-size:18px;">以下开始excel导入导出</span>
//导出 控制器中use PHPExcel; use IOFactory;
phpExcel导入导出终于完成了,赶快尝试一下吧
第二方法 用集成方法 maatwebsite 集成类,但是不支持一些文件。已经修复
http://blog.csdn.net/zhwxl_zyx/article/details/47251491
并修复其中的问题
vendormaatwebsiteexcelsrcMaatwebsiteExcelReadersLaravelExcelReader.php
修改后的版本
https://github.com/yanggg1133/Laravel-Excel
增加
Laravel 4
"maatwebsite/excel": "~1.3"
Laravel 5
"maatwebsite/excel": "~2.0"
添加完后执行 composer update
After updating composer, add the ServiceProvider to
the providers array in app/config/app.php
'MaatwebsiteExcelExcelServiceProvider',
You can use the facade for shorter code. Add this to your aliasses:
'Excel' => 'MaatwebsiteExcelFacadesExcel',
The class is binded to the ioC as excel
$excel = App::make('excel');
Laravel 4
Laravel Excel includes several config settings for import-, export-, view- and CSV-specific settings. Use the artisan publish command to publish the config file to your project.
php artisan config:publish maatwebsite/excel
The config files can now be found
at app/config/packages/maatwebsite/excel
Laravel 5
To publish the config settings in Laravel 5 use:
php artisan vendor:publish
This will add an excel.php
config
file to your config folder.
详细用法请参考官网 http://www.maatwebsite.nl/laravel-excel/docs/getting-started
- "autoload": {
- "classmap": [
- "database",
- "app/libs/phpExcel"
- ],
- "psr-4": {
- "App\": "app/"
- }
- },
5、安装composer,windows下可以在百度上下载
6、运行命令行进入项目根目录,执行“composer dumpautoload”,
7、在控制器中use PHPExcel
8、在方法中实例化phpExccel对象,打印该对象看phpExcel类是否引入成功。
$objPHPExcel = new PHPExcel();
print_r($objPHPExcel);
==========以上是引入phpExcel类步骤(其它第三方类与此类似)============
<span style="font-size:18px;">以下开始excel导入导出</span>
//导出 控制器中use PHPExcel; use IOFactory;
phpExcel导入导出终于完成了,赶快尝试一下吧
第二方法 用集成方法 maatwebsite 集成类,但是不支持一些文件。已经修复
http://blog.csdn.net/zhwxl_zyx/article/details/47251491
并修复其中的问题
vendormaatwebsiteexcelsrcMaatwebsiteExcelReadersLaravelExcelReader.php
修改后的版本
https://github.com/yanggg1133/Laravel-Excel
增加
Laravel 4
"maatwebsite/excel": "~1.3"
Laravel 5
"maatwebsite/excel": "~2.0"
添加完后执行 composer update
After updating composer, add the ServiceProvider to
the providers array in app/config/app.php
'MaatwebsiteExcelExcelServiceProvider',
You can use the facade for shorter code. Add this to your aliasses:
'Excel' => 'MaatwebsiteExcelFacadesExcel',
The class is binded to the ioC as excel
$excel = App::make('excel');
Laravel 4
Laravel Excel includes several config settings for import-, export-, view- and CSV-specific settings. Use the artisan publish command to publish the config file to your project.
php artisan config:publish maatwebsite/excel
The config files can now be found
at app/config/packages/maatwebsite/excel
Laravel 5
To publish the config settings in Laravel 5 use:
php artisan vendor:publish
This will add an excel.php
config
file to your config folder.
详细用法请参考官网 http://www.maatwebsite.nl/laravel-excel/docs/getting-started