https://github.com/racklin/excel-generator
Excel Generator for Laravel
https://github.com/racklin/excel-generator
excel laravel laravel-package
Last synced: about 1 year ago
JSON representation
Excel Generator for Laravel
- Host: GitHub
- URL: https://github.com/racklin/excel-generator
- Owner: racklin
- License: mit
- Created: 2017-08-02T16:12:59.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-07-16T15:26:28.000Z (almost 8 years ago)
- Last Synced: 2024-10-20T09:17:18.990Z (over 1 year ago)
- Topics: excel, laravel, laravel-package
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 3
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple Excel Generator for Laravel
Simple Excel Generator for Laravel using phpexcel library.
This package using json as template and you can pass php array as data to generate Excel xlsx.
# Installation
```json
{
"require": {
"racklin/excel-generator": "dev-master"
}
}
```
Next, add the service provider to `config/app.php`.
```php
'providers' => [
//...
Racklin\ExcelGenerator\ServiceProvider::class,
]
//...
'aliases' => [
//...
'ExcelGen' => Racklin\ExcelGenerator\Facades\ExcelGenerator::class
]
```
# Example
```
$excel = new ExcelGenerator();
$excel->generate('example_01.json', ["name"=>"rack", "cname"=>"阿土伯", "data"=> [
["a"=>"A1", "b"=>"B1"],
["a"=>"A2", "b"=>"B2"],
["a"=>"A3", "b"=>"B2"],
["a"=>"A4", "b"=>"B2"],
["a"=>"A5", "b"=>"B2"],
["a"=>"A6", "b"=>"B2"],
["a"=>"A7", "b"=>"B2"],
["a"=>"A8", "b"=>"B2"],
["a"=>"A9", "b"=>"B2"],
]], '/tmp/example_01.xlsx', 'F');
```
## Laravel Facade
```
ExcelGen::generate('example_01.json', ["name"=>"rack", "cname"=>"阿土伯", "data"=> [
["a"=>"A1", "b"=>"B1"],
["a"=>"A2", "b"=>"B2"],
["a"=>"A3", "b"=>"B2"],
["a"=>"A4", "b"=>"B2"],
["a"=>"A5", "b"=>"B2"],
["a"=>"A6", "b"=>"B2"],
["a"=>"A7", "b"=>"B2"],
["a"=>"A8", "b"=>"B2"],
["a"=>"A9", "b"=>"B2"],
]], '/tmp/example_01.xlsx', 'F');
```
## Laravel version
Current package version works for Laravel 5+.
## License
MIT: https://racklin.mit-license.org/