Replace PHPExcel with PhpSpreadsheet

This commit is contained in:
Kevin MacMartin 2018-04-02 22:52:09 -04:00
parent 5c1e1ef14e
commit d26bbde212
6 changed files with 63 additions and 960 deletions

View file

@ -4,7 +4,8 @@ use App\Http\Requests;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use File; use File;
use Image; use Image;
use Excel; use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use App\Models\Contact; use App\Models\Contact;
use App\Models\Subscriptions; use App\Models\Subscriptions;
@ -65,29 +66,32 @@ class DashboardController extends Controller {
*/ */
public function getExport($model) public function getExport($model)
{ {
// set the name of the spreadsheet // set the filename of the spreadsheet
$sheet_name = ucfirst($model); $filename = preg_replace([ '/\ /', '/[^a-z0-9\-]/' ], [ '-', '' ], strtolower(env('APP_NAME'))) . '-' . $model . '-' . date('m-d-Y');
// set the model using the 'model' request argument // set the model using the 'model' request argument
switch ($model) { switch ($model) {
case 'contact': case 'contact':
$headings = [ 'Date', 'Name', 'Email', 'Message' ]; $headings = [ 'Date', 'Name', 'Email', 'Message' ];
$items = Contact::select('created_at', 'name', 'email', 'message')->get(); $items = Contact::select('created_at', 'name', 'email', 'message')->get()->toArray();
break; break;
case 'subscriptions': case 'subscriptions':
$headings = [ 'Date', 'Email', 'Name' ]; $headings = [ 'Date', 'Email', 'Name' ];
$items = Subscriptions::select('created_at', 'email', 'name')->get(); $items = Subscriptions::select('created_at', 'email', 'name')->get()->toArray();
break; break;
default: default:
abort(404); abort(404);
} }
Excel::create($sheet_name, function($excel) use($sheet_name, $headings, $items) { array_unshift($items, $headings);
$excel->sheet($sheet_name, function($sheet) use($sheet_name, $headings, $items) { $spreadsheet = new Spreadsheet();
$sheet->fromArray($items); $spreadsheet->getActiveSheet()->getDefaultColumnDimension()->setWidth(25);
$sheet->row(1, $headings); $spreadsheet->getActiveSheet()->fromArray($items, NULL, 'A1');
}); $writer = new Xlsx($spreadsheet);
})->store('xls')->export('xls'); header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . $filename . '"');
header('Cache-Control: max-age=0');
$writer->save('php://output');
} }
/** /**

View file

@ -12,7 +12,7 @@
"intervention/image": "^2.4", "intervention/image": "^2.4",
"laravel/framework": "5.6.*", "laravel/framework": "5.6.*",
"laravel/tinker": "~1.0", "laravel/tinker": "~1.0",
"maatwebsite/excel": "^2.1", "phpoffice/phpspreadsheet": "^1.2",
"radic/blade-extensions": "~7.0", "radic/blade-extensions": "~7.0",
"spatie/laravel-newsletter": "^4.2" "spatie/laravel-newsletter": "^4.2"
}, },

308
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "55e02860a209d56ac0602f4cd2df3e7b", "content-hash": "2d5bd23eb8c81610472dc8769d49acde",
"packages": [ "packages": [
{ {
"name": "anahkiasen/underscore-php", "name": "anahkiasen/underscore-php",
@ -1205,64 +1205,6 @@
], ],
"time": "2015-04-20T18:58:01+00:00" "time": "2015-04-20T18:58:01+00:00"
}, },
{
"name": "jeremeamia/SuperClosure",
"version": "2.4.0",
"source": {
"type": "git",
"url": "https://github.com/jeremeamia/super_closure.git",
"reference": "5707d5821b30b9a07acfb4d76949784aaa0e9ce9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jeremeamia/super_closure/zipball/5707d5821b30b9a07acfb4d76949784aaa0e9ce9",
"reference": "5707d5821b30b9a07acfb4d76949784aaa0e9ce9",
"shasum": ""
},
"require": {
"nikic/php-parser": "^1.2|^2.0|^3.0|^4.0",
"php": ">=5.4",
"symfony/polyfill-php56": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0|^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"psr-4": {
"SuperClosure\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jeremy Lindblom",
"email": "jeremeamia@gmail.com",
"homepage": "https://github.com/jeremeamia",
"role": "Developer"
}
],
"description": "Serialize Closure objects, including their context and binding",
"homepage": "https://github.com/jeremeamia/super_closure",
"keywords": [
"closure",
"function",
"lambda",
"parser",
"serializable",
"serialize",
"tokenizer"
],
"time": "2018-03-21T22:21:57+00:00"
},
{ {
"name": "laradic/support", "name": "laradic/support",
"version": "1.0.1", "version": "1.0.1",
@ -1611,84 +1553,6 @@
], ],
"time": "2018-03-01T10:27:04+00:00" "time": "2018-03-01T10:27:04+00:00"
}, },
{
"name": "maatwebsite/excel",
"version": "2.1.27",
"source": {
"type": "git",
"url": "https://github.com/Maatwebsite/Laravel-Excel.git",
"reference": "ea758fe5a9d33e0d88b40f099d1df652a0c99d38"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/ea758fe5a9d33e0d88b40f099d1df652a0c99d38",
"reference": "ea758fe5a9d33e0d88b40f099d1df652a0c99d38",
"shasum": ""
},
"require": {
"illuminate/cache": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"illuminate/config": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"illuminate/filesystem": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"illuminate/support": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"jeremeamia/superclosure": "^2.3",
"nesbot/carbon": "~1.0",
"php": ">=5.5",
"phpoffice/phpexcel": "^1.8.1",
"tijsverkoyen/css-to-inline-styles": "~2.0"
},
"require-dev": {
"mockery/mockery": "~1.0",
"orchestra/testbench": "3.1.*|3.2.*|3.3.*|3.4.*|3.5.*|3.6.*",
"phpseclib/phpseclib": "~1.0",
"phpunit/phpunit": "~4.0"
},
"suggest": {
"illuminate/http": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"illuminate/queue": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"illuminate/routing": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"illuminate/view": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Maatwebsite\\Excel\\ExcelServiceProvider"
],
"aliases": {
"Excel": "Maatwebsite\\Excel\\Facades\\Excel"
}
}
},
"autoload": {
"classmap": [
"src/Maatwebsite/Excel"
],
"psr-0": {
"Maatwebsite\\Excel\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Maatwebsite.nl",
"email": "patrick@maatwebsite.nl"
}
],
"description": "An eloquent way of importing and exporting Excel and CSV in Laravel 4 with the power of PHPExcel",
"keywords": [
"PHPExcel",
"batch",
"csv",
"excel",
"export",
"import",
"laravel"
],
"time": "2018-03-09T13:14:19+00:00"
},
{ {
"name": "monolog/monolog", "name": "monolog/monolog",
"version": "1.23.0", "version": "1.23.0",
@ -1979,33 +1843,59 @@
"time": "2016-05-18T13:57:10+00:00" "time": "2016-05-18T13:57:10+00:00"
}, },
{ {
"name": "phpoffice/phpexcel", "name": "phpoffice/phpspreadsheet",
"version": "1.8.1", "version": "1.2.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHPOffice/PHPExcel.git", "url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
"reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32" "reference": "8380fb3ad28242093c18d0baa9b7e67fb429ea84"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/372c7cbb695a6f6f1e62649381aeaa37e7e70b32", "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/8380fb3ad28242093c18d0baa9b7e67fb429ea84",
"reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32", "reference": "8380fb3ad28242093c18d0baa9b7e67fb429ea84",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-ctype": "*",
"ext-dom": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xml": "*", "ext-xml": "*",
"ext-xmlreader": "*",
"ext-xmlwriter": "*", "ext-xmlwriter": "*",
"php": ">=5.2.0" "ext-zip": "*",
"ext-zlib": "*",
"php": "^5.6|^7.0",
"psr/simple-cache": "^1.0"
},
"require-dev": {
"dompdf/dompdf": "^0.8.0",
"friendsofphp/php-cs-fixer": "@stable",
"jpgraph/jpgraph": "^4.0",
"mpdf/mpdf": "^7.0.0",
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^2.7",
"tecnickcom/tcpdf": "^6.2"
},
"suggest": {
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
"jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
"tecnick.com/tcpdf": "Option for rendering PDF with PDF Writer"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"PHPExcel": "Classes/" "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"LGPL" "LGPL-2.1-or-later"
], ],
"authors": [ "authors": [
{ {
@ -2013,28 +1903,30 @@
"homepage": "http://blog.maartenballiauw.be" "homepage": "http://blog.maartenballiauw.be"
}, },
{ {
"name": "Mark Baker" "name": "Erik Tilt"
}, },
{ {
"name": "Franck Lefevre", "name": "Franck Lefevre",
"homepage": "http://blog.rootslabs.net" "homepage": "http://rootslabs.net"
}, },
{ {
"name": "Erik Tilt" "name": "Mark Baker",
"homepage": "http://markbakeruk.net"
} }
], ],
"description": "PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
"homepage": "http://phpexcel.codeplex.com", "homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
"keywords": [ "keywords": [
"OpenXML", "OpenXML",
"excel", "excel",
"gnumeric",
"ods",
"php", "php",
"spreadsheet", "spreadsheet",
"xls", "xls",
"xlsx" "xlsx"
], ],
"abandoned": "phpoffice/phpspreadsheet", "time": "2018-03-04T20:41:15+00:00"
"time": "2015-05-01T07:00:55+00:00"
}, },
{ {
"name": "psr/container", "name": "psr/container",
@ -3049,62 +2941,6 @@
], ],
"time": "2018-01-30T19:27:44+00:00" "time": "2018-01-30T19:27:44+00:00"
}, },
{
"name": "symfony/polyfill-php56",
"version": "v1.7.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php56.git",
"reference": "ebc999ce5f14204c5150b9bd15f8f04e621409d8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/ebc999ce5f14204c5150b9bd15f8f04e621409d8",
"reference": "ebc999ce5f14204c5150b9bd15f8f04e621409d8",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"symfony/polyfill-util": "~1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.7-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php56\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"time": "2018-01-30T19:27:44+00:00"
},
{ {
"name": "symfony/polyfill-php72", "name": "symfony/polyfill-php72",
"version": "v1.7.0", "version": "v1.7.0",
@ -3160,58 +2996,6 @@
], ],
"time": "2018-01-31T17:43:24+00:00" "time": "2018-01-31T17:43:24+00:00"
}, },
{
"name": "symfony/polyfill-util",
"version": "v1.7.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-util.git",
"reference": "e17c808ec4228026d4f5a8832afa19be85979563"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-util/zipball/e17c808ec4228026d4f5a8832afa19be85979563",
"reference": "e17c808ec4228026d4f5a8832afa19be85979563",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.7-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Util\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony utilities for portability of PHP codes",
"homepage": "https://symfony.com",
"keywords": [
"compat",
"compatibility",
"polyfill",
"shim"
],
"time": "2018-01-31T18:08:44+00:00"
},
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v4.0.6", "version": "v4.0.6",

View file

@ -165,7 +165,6 @@ return [
Radic\BladeExtensions\BladeExtensionsServiceProvider::class, Radic\BladeExtensions\BladeExtensionsServiceProvider::class,
Spatie\Newsletter\NewsletterServiceProvider::class, Spatie\Newsletter\NewsletterServiceProvider::class,
Intervention\Image\ImageServiceProvider::class, Intervention\Image\ImageServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
], ],
@ -220,7 +219,6 @@ return [
* Custom Class Aliases... * Custom Class Aliases...
*/ */
'Image' => Intervention\Image\Facades\Image::class, 'Image' => Intervention\Image\Facades\Image::class,
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
'Language' => App\Utilities\Language::class, 'Language' => App\Utilities\Language::class,
] ]

View file

@ -1,683 +0,0 @@
<?php
return array(
'cache' => array(
/*
|--------------------------------------------------------------------------
| Enable/Disable cell caching
|--------------------------------------------------------------------------
*/
'enable' => true,
/*
|--------------------------------------------------------------------------
| Caching driver
|--------------------------------------------------------------------------
|
| Set the caching driver
|
| Available methods:
| memory|gzip|serialized|igbinary|discISAM|apc|memcache|temp|wincache|sqlite|sqlite3
|
*/
'driver' => 'memory',
/*
|--------------------------------------------------------------------------
| Cache settings
|--------------------------------------------------------------------------
*/
'settings' => array(
'memoryCacheSize' => '32MB',
'cacheTime' => 600
),
/*
|--------------------------------------------------------------------------
| Memcache settings
|--------------------------------------------------------------------------
*/
'memcache' => array(
'host' => 'localhost',
'port' => 11211,
),
/*
|--------------------------------------------------------------------------
| Cache dir (for discISAM)
|--------------------------------------------------------------------------
*/
'dir' => storage_path('cache')
),
'properties' => array(
'creator' => env('APP_NAME', 'Dashboard'),
'lastModifiedBy' => env('APP_NAME', 'Dashboard'),
'title' => 'Spreadsheet Export',
'description' => 'Exported Spreadsheet Data',
'subject' => 'Spreadsheet export',
'keywords' => 'excel, export',
'category' => 'Excel',
'manager' => env('APP_NAME', 'Dashboard'),
'company' => env('APP_NAME', 'Dashboard'),
),
/*
|--------------------------------------------------------------------------
| Sheets settings
|--------------------------------------------------------------------------
*/
'sheets' => array(
/*
|--------------------------------------------------------------------------
| Default page setup
|--------------------------------------------------------------------------
*/
'pageSetup' => array(
'orientation' => 'portrait',
'paperSize' => '9',
'scale' => '100',
'fitToPage' => false,
'fitToHeight' => true,
'fitToWidth' => true,
'columnsToRepeatAtLeft' => array('', ''),
'rowsToRepeatAtTop' => array(0, 0),
'horizontalCentered' => false,
'verticalCentered' => false,
'printArea' => null,
'firstPageNumber' => null,
),
),
/*
|--------------------------------------------------------------------------
| Creator
|--------------------------------------------------------------------------
|
| The default creator of a new Excel file
|
*/
'creator' => env('APP_NAME', 'Dashboard'),
'csv' => array(
/*
|--------------------------------------------------------------------------
| Delimiter
|--------------------------------------------------------------------------
|
| The default delimiter which will be used to read out a CSV file
|
*/
'delimiter' => ',',
/*
|--------------------------------------------------------------------------
| Enclosure
|--------------------------------------------------------------------------
*/
'enclosure' => '"',
/*
|--------------------------------------------------------------------------
| Line endings
|--------------------------------------------------------------------------
*/
'line_ending' => "\r\n"
),
'export' => array(
/*
|--------------------------------------------------------------------------
| Autosize columns
|--------------------------------------------------------------------------
|
| Disable/enable column autosize or set the autosizing for
| an array of columns ( array('A', 'B') )
|
*/
'autosize' => true,
/*
|--------------------------------------------------------------------------
| Autosize method
|--------------------------------------------------------------------------
|
| --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX
| The default is based on an estimate, which does its calculation based
| on the number of characters in the cell value (applying any calculation
| and format mask, and allowing for wordwrap and rotation) and with an
| "arbitrary" adjustment based on the font (Arial, Calibri or Verdana,
| defaulting to Calibri if any other font is used) and a proportional
| adjustment for the font size.
|
| --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT
| The second method is more accurate, based on actual style formatting as
| well (bold, italic, etc), and is calculated by generating a gd2 imagettf
| bounding box and using its dimensions to determine the size; but this
| method is significantly slower, and its accuracy is still dependent on
| having the appropriate fonts installed.
|
*/
'autosize-method' => PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX,
/*
|--------------------------------------------------------------------------
| Auto generate table heading
|--------------------------------------------------------------------------
|
| If set to true, the array indices (or model attribute names)
| will automatically be used as first row (table heading)
|
*/
'generate_heading_by_indices' => true,
/*
|--------------------------------------------------------------------------
| Auto set alignment on merged cells
|--------------------------------------------------------------------------
*/
'merged_cell_alignment' => 'left',
/*
|--------------------------------------------------------------------------
| Pre-calculate formulas during export
|--------------------------------------------------------------------------
*/
'calculate' => false,
/*
|--------------------------------------------------------------------------
| Include Charts during export
|--------------------------------------------------------------------------
*/
'includeCharts' => false,
/*
|--------------------------------------------------------------------------
| Default sheet settings
|--------------------------------------------------------------------------
*/
'sheets' => array(
/*
|--------------------------------------------------------------------------
| Default page margin
|--------------------------------------------------------------------------
|
| 1) When set to false, default margins will be used
| 2) It's possible to enter a single margin which will
| be used for all margins.
| 3) Alternatively you can pass an array with 4 margins
| Default order: array(top, right, bottom, left)
|
*/
'page_margin' => false,
/*
|--------------------------------------------------------------------------
| Value in source array that stands for blank cell
|--------------------------------------------------------------------------
*/
'nullValue' => null,
/*
|--------------------------------------------------------------------------
| Insert array starting from this cell address as the top left coordinate
|--------------------------------------------------------------------------
*/
'startCell' => 'A1',
/*
|--------------------------------------------------------------------------
| Apply strict comparison when testing for null values in the array
|--------------------------------------------------------------------------
*/
'strictNullComparison' => false
),
/*
|--------------------------------------------------------------------------
| Store settings
|--------------------------------------------------------------------------
*/
'store' => array(
/*
|--------------------------------------------------------------------------
| Path
|--------------------------------------------------------------------------
|
| The path we want to save excel file to
|
*/
'path' => storage_path('exports'),
/*
|--------------------------------------------------------------------------
| Return info
|--------------------------------------------------------------------------
|
| Whether we want to return information about the stored file or not
|
*/
'returnInfo' => false
),
/*
|--------------------------------------------------------------------------
| PDF Settings
|--------------------------------------------------------------------------
*/
'pdf' => array(
/*
|--------------------------------------------------------------------------
| PDF Drivers
|--------------------------------------------------------------------------
| Supported: DomPDF, tcPDF, mPDF
*/
'driver' => 'DomPDF',
/*
|--------------------------------------------------------------------------
| PDF Driver settings
|--------------------------------------------------------------------------
*/
'drivers' => array(
/*
|--------------------------------------------------------------------------
| DomPDF settings
|--------------------------------------------------------------------------
*/
'DomPDF' => array(
'path' => base_path('vendor/dompdf/dompdf/')
),
/*
|--------------------------------------------------------------------------
| tcPDF settings
|--------------------------------------------------------------------------
*/
'tcPDF' => array(
'path' => base_path('vendor/tecnick.com/tcpdf/')
),
/*
|--------------------------------------------------------------------------
| mPDF settings
|--------------------------------------------------------------------------
*/
'mPDF' => array(
'path' => base_path('vendor/mpdf/mpdf/')
),
)
)
),
'filters' => array(
/*
|--------------------------------------------------------------------------
| Register read filters
|--------------------------------------------------------------------------
*/
'registered' => array(
'chunk' => 'Maatwebsite\Excel\Filters\ChunkReadFilter'
),
/*
|--------------------------------------------------------------------------
| Enable certain filters for every file read
|--------------------------------------------------------------------------
*/
'enabled' => array()
),
'import' => array(
/*
|--------------------------------------------------------------------------
| Has heading
|--------------------------------------------------------------------------
|
| The sheet has a heading (first) row which we can use as attribute names
|
| Options: true|false|slugged|slugged_with_count|ascii|numeric|hashed|trans|original
|
*/
'heading' => 'slugged',
/*
|--------------------------------------------------------------------------
| First Row with data or heading of data
|--------------------------------------------------------------------------
|
| If the heading row is not the first row, or the data doesn't start
| on the first row, here you can change the start row.
|
*/
'startRow' => 1,
/*
|--------------------------------------------------------------------------
| Cell name word separator
|--------------------------------------------------------------------------
|
| The default separator which is used for the cell names
| Note: only applies to 'heading' settings 'true' && 'slugged'
|
*/
'separator' => '_',
/*
|--------------------------------------------------------------------------
| Include Charts during import
|--------------------------------------------------------------------------
*/
'includeCharts' => false,
/*
|--------------------------------------------------------------------------
| Sheet heading conversion
|--------------------------------------------------------------------------
|
| Convert headings to ASCII
| Note: only applies to 'heading' settings 'true' && 'slugged'
|
*/
'to_ascii' => true,
/*
|--------------------------------------------------------------------------
| Import encoding
|--------------------------------------------------------------------------
*/
'encoding' => array(
'input' => 'UTF-8',
'output' => 'UTF-8'
),
/*
|--------------------------------------------------------------------------
| Calculate
|--------------------------------------------------------------------------
|
| By default cells with formulas will be calculated.
|
*/
'calculate' => true,
/*
|--------------------------------------------------------------------------
| Ignore empty cells
|--------------------------------------------------------------------------
|
| By default empty cells are not ignored
|
*/
'ignoreEmpty' => false,
/*
|--------------------------------------------------------------------------
| Force sheet collection
|--------------------------------------------------------------------------
|
| For a sheet collection even when there is only 1 sheets.
| When set to false and only 1 sheet found, the parsed file will return
| a row collection instead of a sheet collection.
| When set to true, it will return a sheet collection instead.
|
*/
'force_sheets_collection' => false,
/*
|--------------------------------------------------------------------------
| Date format
|--------------------------------------------------------------------------
|
| The format dates will be parsed to
|
*/
'dates' => array(
/*
|--------------------------------------------------------------------------
| Enable/disable date formatting
|--------------------------------------------------------------------------
*/
'enabled' => true,
/*
|--------------------------------------------------------------------------
| Default date format
|--------------------------------------------------------------------------
|
| If set to false, a carbon object will return
|
*/
'format' => false,
/*
|--------------------------------------------------------------------------
| Date columns
|--------------------------------------------------------------------------
*/
'columns' => array()
),
/*
|--------------------------------------------------------------------------
| Import sheets by config
|--------------------------------------------------------------------------
*/
'sheets' => array(
/*
|--------------------------------------------------------------------------
| Example sheet
|--------------------------------------------------------------------------
|
| Example sheet "test" will grab the firstname at cell A2
|
*/
'test' => array(
'firstname' => 'A2'
)
)
),
'views' => array(
/*
|--------------------------------------------------------------------------
| Styles
|--------------------------------------------------------------------------
|
| The default styles which will be used when parsing a view
|
*/
'styles' => array(
/*
|--------------------------------------------------------------------------
| Table headings
|--------------------------------------------------------------------------
*/
'th' => array(
'font' => array(
'bold' => true,
'size' => 12,
)
),
/*
|--------------------------------------------------------------------------
| Strong tags
|--------------------------------------------------------------------------
*/
'strong' => array(
'font' => array(
'bold' => true,
'size' => 12,
)
),
/*
|--------------------------------------------------------------------------
| Bold tags
|--------------------------------------------------------------------------
*/
'b' => array(
'font' => array(
'bold' => true,
'size' => 12,
)
),
/*
|--------------------------------------------------------------------------
| Italic tags
|--------------------------------------------------------------------------
*/
'i' => array(
'font' => array(
'italic' => true,
'size' => 12,
)
),
/*
|--------------------------------------------------------------------------
| Heading 1
|--------------------------------------------------------------------------
*/
'h1' => array(
'font' => array(
'bold' => true,
'size' => 24,
)
),
/*
|--------------------------------------------------------------------------
| Heading 2
|--------------------------------------------------------------------------
*/
'h2' => array(
'font' => array(
'bold' => true,
'size' => 18,
)
),
/*
|--------------------------------------------------------------------------
| Heading 2
|--------------------------------------------------------------------------
*/
'h3' => array(
'font' => array(
'bold' => true,
'size' => 13.5,
)
),
/*
|--------------------------------------------------------------------------
| Heading 4
|--------------------------------------------------------------------------
*/
'h4' => array(
'font' => array(
'bold' => true,
'size' => 12,
)
),
/*
|--------------------------------------------------------------------------
| Heading 5
|--------------------------------------------------------------------------
*/
'h5' => array(
'font' => array(
'bold' => true,
'size' => 10,
)
),
/*
|--------------------------------------------------------------------------
| Heading 6
|--------------------------------------------------------------------------
*/
'h6' => array(
'font' => array(
'bold' => true,
'size' => 7.5,
)
),
/*
|--------------------------------------------------------------------------
| Hyperlinks
|--------------------------------------------------------------------------
*/
'a' => array(
'font' => array(
'underline' => true,
'color' => array('argb' => 'FF0000FF'),
)
),
/*
|--------------------------------------------------------------------------
| Horizontal rules
|--------------------------------------------------------------------------
*/
'hr' => array(
'borders' => array(
'bottom' => array(
'style' => 'thin',
'color' => array('FF000000')
),
)
)
)
)
);

View file

@ -296,7 +296,7 @@ Viewable models and editable models with `export` set to `true` must have an ent
switch ($model) { switch ($model) {
case 'contact': case 'contact':
$headings = [ 'Date', 'Name', 'Email', 'Message' ]; $headings = [ 'Date', 'Name', 'Email', 'Message' ];
$items = Contact::select('created_at', 'name', 'email', 'message')->get(); $items = Contact::select('created_at', 'name', 'email', 'message')->get()->toArray();
break; break;
default: default:
abort(404); abort(404);