├── .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 | [](https://travis-ci.org/Maatwebsite/Laravel-Excel)
38 | [](https://packagist.org/packages/maatwebsite/excel) [](https://packagist.org/packages/maatwebsite/excel) [](https://packagist.org/packages/maatwebsite/excel)
39 | [](https://packagist.org/packages/maatwebsite/excel)
40 | [](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 |