├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── composer.json ├── docs ├── blade.md ├── blade │ ├── load-view.md │ ├── styling.md │ └── vars.md ├── borders.md ├── changelog.md ├── changelog │ ├── version-1.md │ └── version-2.md ├── export.md ├── export │ ├── array.md │ ├── autofilter.md │ ├── autosize.md │ ├── call.md │ ├── cells.md │ ├── export.md │ ├── format.md │ ├── freeze.md │ ├── injection.md │ ├── merge.md │ ├── rows.md │ ├── sheet-styling.md │ ├── sheets.md │ ├── simple.md │ ├── sizing.md │ └── store.md ├── formats.md ├── getting-started.md ├── getting-started │ ├── config.md │ ├── contributing.md │ ├── installation.md │ ├── license.md │ └── requirements.md ├── import.md ├── import │ ├── basics.md │ ├── batch.md │ ├── cache.md │ ├── calculation.md │ ├── chunk.md │ ├── config.md │ ├── convert.md │ ├── dates.md │ ├── edit.md │ ├── extra.md │ ├── formatting.md │ ├── injection.md │ ├── results.md │ └── select.md ├── merge.md ├── reference-guide.md └── reference-guide │ ├── borders.md │ ├── closures.md │ ├── css-styles.md │ ├── file-properties.md │ ├── formatting.md │ └── sheet-properties.md ├── phpunit.xml ├── provides.json ├── src ├── Maatwebsite │ └── Excel │ │ ├── Classes │ │ ├── Cache.php │ │ ├── FormatIdentifier.php │ │ ├── LaravelExcelWorksheet.php │ │ └── PHPExcel.php │ │ ├── Collections │ │ ├── CellCollection.php │ │ ├── ExcelCollection.php │ │ ├── RowCollection.php │ │ └── SheetCollection.php │ │ ├── Excel.php │ │ ├── ExcelServiceProvider.php │ │ ├── Exceptions │ │ └── LaravelExcelException.php │ │ ├── Facades │ │ └── Excel.php │ │ ├── Files │ │ ├── ExcelFile.php │ │ ├── ExportHandler.php │ │ ├── File.php │ │ ├── ImportHandler.php │ │ └── NewExcelFile.php │ │ ├── Filters │ │ └── ChunkReadFilter.php │ │ ├── Parsers │ │ ├── CssParser.php │ │ ├── ExcelParser.php │ │ └── ViewParser.php │ │ ├── Readers │ │ ├── Batch.php │ │ ├── ConfigReader.php │ │ ├── HtmlReader.php │ │ └── LaravelExcelReader.php │ │ └── Writers │ │ ├── CellWriter.php │ │ └── LaravelExcelWriter.php └── config │ └── excel.php └── tests ├── .gitkeep ├── Collections └── CellCollectionTest.php ├── Excel ├── ExcelTestCase.php └── ExcelTester.php ├── Files ├── CsvExcelFileTest.php ├── ExcelFileTest.php ├── NewExcelFileTest.php ├── classes │ ├── CsvTestImport.php │ ├── TestExport.php │ ├── TestExportHandler.php │ ├── TestImport.php │ └── TestImportHandler.php └── files │ ├── test-custom.csv │ └── test.csv ├── Filters ├── ChunkReadFilterTest.php ├── RegisterFilterTestCase.php └── files │ ├── multi.xls │ ├── sample.csv │ ├── sample.xls │ └── sample.xlsx ├── Readers ├── ChineseXlsReaderTest.php ├── CsvReaderTest.php ├── CustomValueBinderTest.php ├── MultipleSheetsXlsReaderTest.php ├── ReaderTest.php ├── XlsReaderTest.php ├── XlsxReaderTest.php ├── ZerosHandlingReaderTest.php ├── files │ ├── chinese.xls │ ├── customBinder.csv │ ├── multiple.xls │ ├── test.csv │ ├── test.xls │ ├── test.xlsx │ └── zeros.xls └── traits │ ├── ImportTrait.php │ └── SingleImportTestingTrait.php ├── TestCase.php ├── TestConfig.php ├── TestServiceProvider.php └── Writers ├── ExcelWriterTest.php └── exports └── .gitignore /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | composer.phar 3 | composer.lock 4 | .DS_Store -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.4 5 | - 5.5 6 | - 5.6 7 | 8 | before_script: 9 | - travis_retry composer self-update 10 | - travis_retry composer install --prefer-source --no-interaction 11 | 12 | script: phpunit 13 | 14 | matrix: 15 | allow_failures: 16 | - php: hhvm 17 | fast_finish: true -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Laravel Excel v2.0.0 for Laravel 5 2 | 3 | Looking for Laravel Excel for Laravel 4? Visit the [`1.3` branch](https://github.com/Maatwebsite/Laravel-Excel/tree/1.3) 4 | 5 | [](http://www.maatwebsite.nl/laravel-excel/docs) 6 | [](http://www.maatwebsite.nl/vacature-php-programmeur-maastricht) 7 | 8 | Laravel Excel brings the power of PHPOffice's PHPExcel to Laravel 5 with a touch of the Laravel Magic. It includes features like: importing Excel and CSV to collections, exporting models, array's and views to Excel, importing batches of files and importing a file by a config file. 9 | 10 | - Import into Laravel **Collections** 11 | - Export **Blade views** to Excel and CSV with optional CSS styling 12 | - **Batch** imports 13 | - A lot of optional **config settings** 14 | - Easy **cell caching** 15 | - Chunked importer 16 | - ExcelFile method injections 17 | - Editing existing Excel files 18 | - **Advanced import** by config files 19 | - and many more... 20 | 21 | --- 22 | 23 | ```php 24 | Excel::create('Laravel Excel', function($excel) { 25 | 26 | $excel->sheet('Excel sheet', function($sheet) { 27 | 28 | $sheet->setOrientation('landscape'); 29 | 30 | }); 31 | 32 | })->export('xls'); 33 | ``` 34 | 35 | --- 36 | 37 | [![Build Status](https://travis-ci.org/Maatwebsite/Laravel-Excel.svg?branch=master)](https://travis-ci.org/Maatwebsite/Laravel-Excel) 38 | [![Latest Stable Version](https://poser.pugx.org/maatwebsite/excel/v/stable.png)](https://packagist.org/packages/maatwebsite/excel) [![Total Downloads](https://poser.pugx.org/maatwebsite/excel/downloads.png)](https://packagist.org/packages/maatwebsite/excel) [![License](https://poser.pugx.org/maatwebsite/excel/license.png)](https://packagist.org/packages/maatwebsite/excel) 39 | [![Monthly Downloads](https://poser.pugx.org/maatwebsite/excel/d/monthly.png)](https://packagist.org/packages/maatwebsite/excel) 40 | [![Daily Downloads](https://poser.pugx.org/maatwebsite/excel/d/daily.png)](https://packagist.org/packages/maatwebsite/excel) 41 | 42 | #Installation 43 | 44 | Require this package in your `composer.json` and update composer. This will download the package and PHPExcel of PHPOffice. 45 | 46 | ```php 47 | "maatwebsite/excel": "~2.0.0" 48 | ``` 49 | 50 | After updating composer, add the ServiceProvider to the providers array in `config/app.php` 51 | 52 | ```php 53 | 'Maatwebsite\Excel\ExcelServiceProvider', 54 | ``` 55 | 56 | You can use the facade for shorter code. Add this to your aliases: 57 | 58 | ```php 59 | 'Excel' => 'Maatwebsite\Excel\Facades\Excel', 60 | ``` 61 | 62 | The class is bound to the ioC as `excel` 63 | 64 | ```php 65 | $excel = App::make('excel'); 66 | ``` 67 | 68 | To publish the config settings in Laravel 5 use: 69 | 70 | ```php 71 | php artisan vendor:publish 72 | ``` 73 | 74 | This will add an `excel.php` config file to your config folder. 75 | 76 | # Documentation 77 | 78 | The complete documentation can be found at: [http://www.maatwebsite.nl/laravel-excel/docs](http://www.maatwebsite.nl/laravel-excel/docs) 79 | 80 | # Contributing 81 | 82 | **ALL** bug fixes should be made to appropriate branch (e.g. `2.0` for 2.0.* bug fixes). Bug fixes should never be sent to the `master` branch. 83 | 84 | More about contributing can be found at: [http://www.maatwebsite.nl/laravel-excel/docs/getting-started#contributing](http://www.maatwebsite.nl/laravel-excel/docs/getting-started#contributing) 85 | 86 | # License 87 | 88 | This package is licensed under LGPL. You are free to use it in personal and commercial projects. The code can be forked and modified, but the original copyright author should always be included! 89 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "maatwebsite/excel", 3 | "description": "An eloquent way of importing and exporting Excel and CSV in Laravel 4 with the power of PHPExcel", 4 | "license": "LGPL", 5 | "keywords": [ 6 | "laravel", 7 | "phpexcel", 8 | "excel", 9 | "csv", 10 | "export", 11 | "import", 12 | "batch" 13 | ], 14 | "authors": [ 15 | { 16 | "name": "Maatwebsite.nl", 17 | "email": "patrick@maatwebsite.nl" 18 | } 19 | ], 20 | "require": { 21 | "php": ">=5.3.0", 22 | "phpoffice/phpexcel": "~1.8.0", 23 | "illuminate/cache": "~5.0", 24 | "illuminate/config": "~5.0", 25 | "illuminate/filesystem": "~5.0", 26 | "illuminate/support": "~5.0", 27 | "nesbot/carbon": "~1.0", 28 | "tijsverkoyen/css-to-inline-styles": "~1.5" 29 | }, 30 | "require-dev": { 31 | "phpseclib/phpseclib": ">=0.3.7", 32 | "phpunit/phpunit": "~4.0", 33 | "mockery/mockery": "~0.9", 34 | "orchestra/testbench": "~3.0.0" 35 | }, 36 | "suggest": { 37 | "illuminate/http": "~5.0", 38 | "illuminate/routing": "~5.0", 39 | "illuminate/view": "~5.0" 40 | }, 41 | "autoload": { 42 | "classmap": [ 43 | "src/Maatwebsite/Excel", 44 | "tests/TestCase.php" 45 | ], 46 | "psr-0": { 47 | "Maatwebsite\\Excel\\": "src/" 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /docs/blade.md: -------------------------------------------------------------------------------- 1 | @include:Loading a view|load-view 2 | @include:Passing variables|vars 3 | @include:Styling sheets|styling -------------------------------------------------------------------------------- /docs/blade/load-view.md: -------------------------------------------------------------------------------- 1 | # @Blade to Excel 2 | 3 | We can utilise the magic of Laravel's Blade engine to power our Excel export. Sharing a view, loading a view per sheet, creating a html table inside a view, basic CSS styling, ... 4 | 5 | # Loading a view for a single sheet 6 | 7 | We can load a view for every sheet we create with `->loadView()`. 8 | 9 | Excel::create('New file', function($excel) { 10 | 11 | $excel->sheet('New sheet', function($sheet) { 12 | 13 | $sheet->loadView('folder.view'); 14 | 15 | }); 16 | 17 | }); 18 | 19 | # Using different views for different sheets 20 | 21 | Excel::create('New file', function($excel) { 22 | 23 | $excel->sheet('First sheet', function($sheet) { 24 | 25 | $sheet->loadView('view_first'); 26 | }); 27 | 28 | $excel->sheet('Second sheet', function($sheet) { 29 | 30 | $sheet->loadView('view_second'); 31 | }); 32 | 33 | }); 34 | 35 | # Sharing a view for all sheets 36 | 37 | We can share a view for all sheets with `shareView()`. 38 | 39 | Excel::shareView('folder.view')->create(); 40 | 41 | # Unsetting a view for a sheet 42 | 43 | When we are using a shared view, but we don't want to use a view for the current sheet, we can use `->unsetView()`. 44 | 45 | $sheet->unsetView(); -------------------------------------------------------------------------------- /docs/blade/styling.md: -------------------------------------------------------------------------------- 1 | # Styling sheets 2 | 3 | ### General styling 4 | 5 | If you want to change the general styling of your sheet (not cell or range specific), you can use the `->setStyle()` method or any of the other setters which can be found inside the export documentation. 6 | 7 | // Font family 8 | $sheet->setFontFamily('Comic Sans MS'); 9 | 10 | // Set font with ->setStyle()` 11 | $sheet->setStyle(array( 12 | 'font' => array( 13 | 'name' => 'Calibri', 14 | 'size' => 12, 15 | 'bold' => true 16 | ) 17 | )); 18 | 19 | ### Styling with PHPExcel methods 20 | 21 | It's possible to style the sheets and specific cells with help of PHPExcel methods. This package includes a lot of shortcuts (see export documentation), but also always the use of the native methods. 22 | 23 | // Set background color for a specific cell 24 | $sheet->getStyle('A1')->applyFromArray(array( 25 | 'fill' => array( 26 | 'type' => PHPExcel_Style_Fill::FILL_SOLID, 27 | 'color' => array('rgb' => 'FF0000') 28 | ) 29 | )); 30 | 31 | ### Using HTML tags 32 | 33 | Most of the HTML tags are supported. 34 | 35 | 36 | 37 | 38 |

Big title

39 | 40 | 41 | Bold cell 42 | Bold cell 43 | 44 | 45 | Italic cell 46 | 47 | 48 | 49 | 50 | 51 | 52 | > Inside the `view.php` config you can change how these tags will be interpreted by Excel by default. 53 | 54 | ### Using HTML attributes 55 | 56 | Some of the basic styling can be done with HTML attributes. 57 | 58 | 59 | 60 | 61 | Big title 62 | 63 | 64 | Bold cell 65 | 66 | 67 | Bold cell 68 | 69 | 70 | Italic cell 71 | 72 | 73 | Cell with width of 100 74 | 75 | 76 | Cell with height of 100 77 | 78 | 79 | 80 | ### Styling through inline-styles 81 | 82 | It's possible to use inline styles inside your view files. Most of the general styles are supported. 83 | 84 | 85 | 86 | 87 | Cell 88 | 89 | 90 | 91 | > Inside the reference guide you can find a list of supported styles. 92 | 93 | ### Styling through external CSS file 94 | 95 | Styling can be done through an external CSS file. 96 | 97 | External css file: 98 | 99 | #cell { 100 | background-color: #000000; 101 | color: #ffffff; 102 | } 103 | 104 | .cell { 105 | background-color: #000000; 106 | color: #ffffff; 107 | } 108 | 109 | tr td { 110 | background-color: #ffffff; 111 | } 112 | 113 | tr > td { 114 | border-bottom: 1px solid #000000; 115 | } 116 | 117 | Table: 118 | 119 | 120 | 121 | {{ HTML::style('css/table.css') }} 122 | 123 | 124 | Cell 125 | 126 | 127 | Cell 128 | 129 | 130 | 131 | > Inside the reference guide you can find a list of supported styles. 132 | 133 | > It's advised to include `` into the view to fix problems with UTF-8 encoding. -------------------------------------------------------------------------------- /docs/blade/vars.md: -------------------------------------------------------------------------------- 1 | # Passing variables to the view 2 | 3 | ### As parameter 4 | 5 | We can pass variables to the view by using the second parameter inside the `loadView()` method. 6 | 7 | $sheet->loadView('view', array('key' => 'value')); 8 | 9 | ### With with() 10 | 11 | Alternatively you can use the `with()` method which works the same as with Laravel views. 12 | 13 | // Using normal with() 14 | $sheet->loadView('view') 15 | ->with('key', 'value'); 16 | 17 | // using dynamic with() 18 | $sheet->loadView('view') 19 | ->withKey('value'); -------------------------------------------------------------------------------- /docs/borders.md: -------------------------------------------------------------------------------- 1 | PHPExcel_Style_Border::BORDER_NONE = 'none' 2 | PHPExcel_Style_Border::BORDER_DASHDOT = 'dashDot' 3 | PHPExcel_Style_Border::BORDER_DASHDOTDOT = 'dashDotDot' 4 | PHPExcel_Style_Border::BORDER_DASHED = 'dashed' 5 | PHPExcel_Style_Border::BORDER_DOTTED = 'dotted' 6 | PHPExcel_Style_Border::BORDER_DOUBLE = 'double' 7 | PHPExcel_Style_Border::BORDER_HAIR = 'hair' 8 | PHPExcel_Style_Border::BORDER_MEDIUM = 'medium' 9 | PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT = 'mediumDashDot' 10 | PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT = 'mediumDashDotDot' 11 | PHPExcel_Style_Border::BORDER_MEDIUMDASHED = 'mediumDashed' 12 | PHPExcel_Style_Border::BORDER_SLANTDASHDOT = 'slantDashDot' 13 | PHPExcel_Style_Border::BORDER_THICK = 'thick' 14 | PHPExcel_Style_Border::BORDER_THIN = 'thin' -------------------------------------------------------------------------------- /docs/changelog.md: -------------------------------------------------------------------------------- 1 | @include:Version 1|version-1 2 | @include:Version 2|version-2 3 | -------------------------------------------------------------------------------- /docs/changelog/version-1.md: -------------------------------------------------------------------------------- 1 | # Version 1 2 | 3 | ### 1.3.5 4 | - PHPExcel 1.8.1 compatibility 5 | - Clean-up ServiceProvider 6 | - Fix short array syntax for PHP5.3 7 | 8 | ### 1.3.4 9 | - Fix usage of sheet callback when modifying an existing file 10 | - Modifying existing files improvements (support style overriding) 11 | - Add text-indent support to HtmlReader 12 | - Add simple sheet password protection 13 | - Add support for exporting multiple pdf pages 14 | - Add inline cell formatting to blade 15 | 16 | ### 1.3.3 17 | - Fix issue with different start row in chunk filter 18 | 19 | ### 1.3.2 20 | - Custom value binders 21 | - Html reader update 22 | 23 | ### 1.3.1 24 | - Fix short array syntax 25 | 26 | ### 1.3.0 27 | - Additional headers with export() 28 | - Float, integer, string, timestamps problems 29 | - Cell content ending by zeros 30 | - Images in html 31 | - Font family bug 32 | - Setting row number of row with headings 33 | 34 | ### 1.2.3 35 | - PDF writer 36 | - Include charts config 37 | - Chunk filter with selected sheet 38 | - Compatibility fix with new PHPExcel release 39 | - setDateColumns fix 40 | - Optional dependencies to require-dev 41 | - Several bugfixes 42 | 43 | ### 1.2.2 44 | - Chunk filter fixes 45 | - Isset() CellCollection fixes 46 | - PHP 5.3 support 47 | - Missing border styles 48 | - Add CSV settings (delimiter, enclosure, lineEnding) to ExcelFile objects 49 | 50 | ### 1.2.1 51 | - Fix with() method parameters 52 | 53 | ### 1.2.0 54 | - Filters 55 | - Chunk filter (with chunked importer) 56 | - ExcelFile (method) injections 57 | - NewExcelFile (method) injections 58 | - Edit existing worksheets 59 | - Converting existing worksheet 60 | - Laravel 4.* + 5.0 support 61 | 62 | ### 1.1.9 63 | - PHP 5.3 fixes 64 | 65 | ### 1.1.8 66 | - PHP 5.3 support 67 | - fromArray bugfix 68 | 69 | ### 1.1.7 70 | - Fix heading generation for export with `->fromArray()` 71 | - Bugfix for non-Unix kernels 72 | - Enhanced CSS parser (thanks to `tijsverkoyen/CssToInlineStyles`) 73 | - Support for nested CSS styles 74 | - Support for multiple css attributes per class 75 | - Support for internal and external CSS files 76 | - Support for inline style blocks (`