Skip to content

Commit

Permalink
Update readme + documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbrouwers committed Sep 19, 2014
1 parent c6b43f9 commit dbea0fb
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
## Laravel Excel v1.1.8
## Laravel Excel v1.2.0

[<img src="http://www.maatwebsite.nl/img/excel_banner.jpg"/>](http://www.maatwebsite.nl/laravel-excel/docs)

Laravel Excel brings the power of PHPOffice's PHPExcel to Laravel 4.* 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.
Laravel Excel brings the power of PHPOffice's PHPExcel to Laravel 4 and 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.

- Import into Laravel **Collections**
- Export **Blade views** to Excel and CSV with optional CSS styling
- **Batch** imports
- A lot of optional **config settings**
- Easy **cell caching**
- Chunked importer
- ExcelFile method injections (Laravel ~5.0)
- Editing existing Excel files
- **Advanced import** by config files
- and many more...

Expand Down Expand Up @@ -38,7 +41,7 @@ Excel::create('Laravel Excel', function($excel) {
Require this package in your `composer.json` and update composer. This will download the package and PHPExcel of PHPOffice.

```php
"maatwebsite/excel": "1.*"
"maatwebsite/excel": "~1.2.0"
```

After updating composer, add the ServiceProvider to the providers array in `app/config/app.php`
Expand All @@ -65,7 +68,7 @@ The complete documentation can be found at: [http://www.maatwebsite.nl/laravel-e

# Contributing

**ALL** bug fixes should be made to appropriate branch (e.g. `1.1` for 1.1.* bug fixes). Bug fixes should never be sent to the `master` branch.
**ALL** bug fixes should be made to appropriate branch (e.g. `1.2` for 1.2.* bug fixes). Bug fixes should never be sent to the `master` branch.

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)

Expand Down
9 changes: 9 additions & 0 deletions docs/changelog/version-1.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Version 1

### 1.2.0
- Filters
- Chunk filter (with chunked importer)
- ExcelFile (method) injections
- NewExcelFile (method) injections
- Edit existing worksheets
- Converting existing worksheet
- Laravel 4.* + 5.0 support

### 1.1.8
- PHP 5.3 support
- fromArray bugfix
Expand Down
1 change: 1 addition & 0 deletions docs/export.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@include:Creating a new file|simple
@include:Exporting|export
@include:NewExcelFile injections|injection
@include:Store to server|store
@include:Creating Sheets|sheets
@include:Creatings Sheets From array|array
Expand Down
61 changes: 61 additions & 0 deletions docs/export/injection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# NewExcelFile injections

Following the Laravel 5.0 philosophy with its new awesome FormRequest injections, we introduce you NewExcelFile injections.

## NewExcelFile class

This NewExcelFile is a wrapper for a new Excel file. Inside the `getFilename()` you can declare the wanted filename.

class UserListExport extends \Maatwebsite\Excel\Files\NewExcelFile {

public function getFilename()
{
return 'filename';
}
}

## Usage

You can inject these NewExcelFiles inside the __constructor or inside the method (when using Laravel 5.0), in e.g. the controller.

class ExampleController extends Controller {

public function exportUserList(UserListExport $export)
{
// work on the export
$export->sheet('sheetName', function($sheet)
{

});
}

}

## Export Handlers

To decouple your Excel-export code completely from the controller, you can use the export handlers.

class ExampleController extends Controller {

public function exportUserList(UserListExport $export)
{
// Handle the export
$export->handleExport();
}

}

The `handleExport()` method will dynamically call a handler class which is your class name appended with `Handler`

class UserListExportHandler implements \Maatwebsite\Excel\Files\ExportHandler {

public function handle(UserListExport $export)
{
// work on the export
$export->sheet('sheetName', function($sheet)
{

});
}

}
4 changes: 4 additions & 0 deletions docs/import.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
@include:Importing a file|basics
@include:ExcelFile injections|injection
@include:Handling results|results
@include:Selecting sheets and columns|select
@include:Dates|dates
@include:Calculation|calculation
@include:Caching and cell caching|cache
@include:Chunk importing|chunk
@include:Batch import|batch
@include:Import by config|config
@include:Edit existing files|edit
@include:Converting|convert
@include:Extra|extra
42 changes: 42 additions & 0 deletions docs/import/chunk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Chunk importer

When dealing with big files, it's better to import the data in big chunks. You can enable this with `filter('chunk');
To import it into chunks you can use `chunk($size, $callback)` instead of the normal `get()`. The first parameter is the size of the chunk. The second parameter is a closure which will return the results.

Excel::filter('chunk')->load('file.csv')->chunk(250, function($results)
{
foreach($results as $row)
{
// do stuff
}
});

When working with ExcelFile injections (instead the constructor or as method injection), you can enable the chunk filter inside the ExcelFile class

ExcelFile class example:

class UserListImport extends \Maatwebsite\Excel\Files\ExcelFile {

public function getFile()
{
return 'file.csv';
}

public function getFilters()
{
return [
'chunk'
];
}

}

Injected ExcelFile example:

public function importUserList(UserListImport $import)
{
$import->chunk(250, function($results)
{
// do stuff
})
}
9 changes: 9 additions & 0 deletions docs/import/convert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Converting

You can convert from one filetype to another by using `->convert()`

Excel::load('file.csv', function($file) {

// modify stuff

})->convert('xls');
9 changes: 9 additions & 0 deletions docs/import/edit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Editing existing files

You can edit existing Excel files, by loading them and after modication exporting them.

Excel::load('file.csv', function($file) {

// modify stuff

})->export('csv');
75 changes: 75 additions & 0 deletions docs/import/injection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# ExcelFile injections

Following the Laravel 5.0 philosophy with its new awesome FormRequest injections, we introduce you ExcelFile injections.

## ExcelFile class

This class is a wrapper for a file on your server. Inside the `getFile()` method you return the filename and it's location. Inside the `getFilters()` method you can enable filters, like the chunk filter.

class UserListImport extends \Maatwebsite\Excel\Files\ExcelFile {

public function getFile()
{
return storage_path('exports') . '/file.csv';
}

public function getFilters()
{
return [
'chunk'
];
}

}

If you want to have the `getFile()` dynamic based on user's input, you can easily do:

public function getFile()
{
// Import a user provided file
$file = Input::file('report');
$filename = $this->doSomethingLikeUpload($file);

// Return it's location
return $filename;
}

## Usage

You can inject these ExcelFiles inside the __constructor or inside the method (when using Laravel 5.0), in e.g. the controller.

class ExampleController extends Controller {

public function importUserList(UserListImport $import)
{
// get the results
$results = $import->get();
}

}

## Import Handlers

To decouple your Excel-import code completely from the controller, you can use the import handlers.

class ExampleController extends Controller {

public function importUserList(UserListImport $import)
{
// Handle the import
$import->handleImport();
}

}

The `handleImport()` method will dynamically call a handler class which is your class name appended with `Handler`

class UserListImportHandler implements \Maatwebsite\Excel\Files\ImportHandler {

public function handle(UserListImport $import)
{
// get the results
$results = $import->get();
}

}

0 comments on commit dbea0fb

Please sign in to comment.