Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at patrick@maatwebsite.nl. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View File

@@ -1,345 +1,21 @@
GNU LESSER GENERAL PUBLIC LICENSE
MIT License
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
Copyright (c) Maatwebsite
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -2,7 +2,7 @@
Looking for Laravel Excel for Laravel 4? Visit the [`1.3` branch](https://github.com/Maatwebsite/Laravel-Excel/tree/1.3)
[<img src="http://www.maatwebsite.nl/img/excel_banner.jpg"/>](http://www.maatwebsite.nl/laravel-excel/docs)
[<img src="http://www.maatwebsite.nl/img/excel_banner.jpg"/>](https://laravel-excel.maatwebsite.nl/)
[<img src="https://cloud.githubusercontent.com/assets/7728097/6332170/1b495af2-bb84-11e4-9a93-34a9abc01840.jpg"/>](http://www.maatwebsite.nl/vacature-php-programmeur-maastricht)
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.
@@ -39,23 +39,23 @@ Excel::create('Laravel Excel', function($excel) {
[![Monthly Downloads](https://poser.pugx.org/maatwebsite/excel/d/monthly.png)](https://packagist.org/packages/maatwebsite/excel)
[![Daily Downloads](https://poser.pugx.org/maatwebsite/excel/d/daily.png)](https://packagist.org/packages/maatwebsite/excel)
[![Help the project](http://www.pledgie.com/campaigns/30385.png?skin_name=chrome)](http://pledgie.com/campaigns/30385)
#Installation
# Installation
Require this package in your `composer.json` and update composer. This will download the package and PHPExcel of PHPOffice.
```php
"maatwebsite/excel": "~2.1.0"
composer require "maatwebsite/excel:~2.1.0"
```
After updating composer, add the ServiceProvider to the providers array in `config/app.php`
In Laravel 5.5 or higher, this package will be automatically discovered and you can safely skip the following two steps.
If using Laravel 5.4 or lower, after updating composer, add the ServiceProvider to the providers array in `config/app.php`
```php
Maatwebsite\Excel\ExcelServiceProvider::class,
```
You can use the facade for shorter code. Add this to your aliases:
You can use the facade for shorter code; if using Laravel 5.4 or lower, add this to your aliases:
```php
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
@@ -77,7 +77,7 @@ This will add an `excel.php` config file to your config folder.
# Documentation
The complete documentation can be found at: [http://www.maatwebsite.nl/laravel-excel/docs](http://www.maatwebsite.nl/laravel-excel/docs)
The complete documentation can be found at: [https://laravel-excel.maatwebsite.nl/docs](https://laravel-excel.maatwebsite.nl/docs)
# Support
@@ -87,8 +87,14 @@ Support only through Github. Please don't mail us about issues, make a Github is
**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.
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)
More about contributing can be found at: [https://laravel-excel.maatwebsite.nl/docs/2.1/getting-started/contributing](https://laravel-excel.maatwebsite.nl/docs/2.1/getting-started/contributing)
# License
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!
This package is licensed under MIT. 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!
# FAQ
1) Chunk importer only imports the first row
Check that auto_detect_line_endings in your php.ini is set to true.

View File

@@ -1,7 +1,7 @@
{
"name": "maatwebsite/excel",
"description": "An eloquent way of importing and exporting Excel and CSV in Laravel 4 with the power of PHPExcel",
"license": "LGPL",
"license": "MIT",
"keywords": [
"laravel",
"phpexcel",
@@ -19,25 +19,26 @@
],
"require": {
"php": ">=5.5",
"phpoffice/phpexcel": "1.8.*",
"illuminate/cache": "5.0.*|5.1.*|5.2.*|5.3.*",
"illuminate/config": "5.0.*|5.1.*|5.2.*|5.3.*",
"illuminate/filesystem": "5.0.*|5.1.*|5.2.*|5.3.*",
"illuminate/support": "5.0.*|5.1.*|5.2.*|5.3.*",
"phpoffice/phpexcel": "^1.8.1",
"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",
"tijsverkoyen/css-to-inline-styles": "~1.5"
"tijsverkoyen/css-to-inline-styles": "~2.0"
},
"require-dev": {
"phpseclib/phpseclib": "~1.0",
"phpunit/phpunit": "~4.0",
"mockery/mockery": "~0.9",
"orchestra/testbench": "3.1.*"
"mockery/mockery": "~1.0",
"orchestra/testbench": "3.1.*|3.2.*|3.3.*|3.4.*|3.5.*|3.6.*"
},
"suggest": {
"illuminate/http": "5.0.*|5.1.*|5.2.*|5.3.*",
"illuminate/routing": "5.0.*|5.1.*|5.2.*|5.3.*",
"illuminate/view": "5.0.*|5.1.*|5.2.*|5.3.*",
"illuminate/queue": "5.0.*|5.1.*|5.2.*|5.3.*"
"illuminate/http": "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.*",
"illuminate/queue": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*"
},
"autoload": {
"classmap": [
@@ -51,5 +52,15 @@
"classmap": [
"tests/TestCase.php"
]
}
},
"extra": {
"laravel": {
"providers": [
"Maatwebsite\\Excel\\ExcelServiceProvider"
],
"aliases": {
"Excel": "Maatwebsite\\Excel\\Facades\\Excel"
}
}
}
}

View File

@@ -1,7 +1,6 @@
<?php namespace Maatwebsite\Excel\Classes;
use PHPExcel_Settings;
use Illuminate\Support\Facades\Config;
use PHPExcel_CachedObjectStorageFactory;
class Cache {
@@ -16,7 +15,7 @@ class Cache {
* Available caching drivers
* @var array
*/
protected $available = array(
protected $available = [
'memory' => 'cache_in_memory',
'gzip' => 'cache_in_memory_gzip',
'serialized' => 'cache_in_memory_serialized',
@@ -28,7 +27,7 @@ class Cache {
'wincache' => 'cache_to_wincache',
'sqlite' => 'cache_to_sqlite',
'sqlite3' => 'cache_to_sqlite3'
);
];
/**
* The name of the config file
@@ -42,8 +41,8 @@ class Cache {
public function __construct()
{
// Get driver and settings from the config
$this->driver = Config::get($this->configName . '.driver', 'memory');
$this->settings = Config::get($this->configName . '.settings', array());
$this->driver = config($this->configName . '.driver', 'memory');
$this->settings = config($this->configName . '.settings', []);
// Init if caching is enabled
if ($this->isEnabled())
@@ -97,19 +96,19 @@ class Cache {
case 'memcache':
// Add extra memcache settings
$this->settings = array_merge($this->settings, array(
'memcacheServer' => Config::get($this->configName . '.memcache.host', 'localhost'),
'memcachePort' => Config::get($this->configName . '.memcache.port', 11211)
));
$this->settings = array_merge($this->settings, [
'memcacheServer' => config($this->configName . '.memcache.host', 'localhost'),
'memcachePort' => config($this->configName . '.memcache.port', 11211)
]);
break;
case 'discISAM':
// Add dir
$this->settings = array_merge($this->settings, array(
'dir' => Config::get($this->configName . '.dir', storage_path('cache')),
));
$this->settings = array_merge($this->settings, [
'dir' => config($this->configName . '.dir', storage_path('cache')),
]);
break;
}
@@ -121,6 +120,6 @@ class Cache {
*/
public function isEnabled()
{
return Config::get($this->configName . '.enable', true) ? true : false;
return config($this->configName . '.enable', true) ? true : false;
}
}

View File

@@ -12,7 +12,7 @@ class FormatIdentifier {
* @var array
* @access protected
*/
protected $formats = array(
protected $formats = [
'Excel2007',
'Excel5',
'Excel2003XML',
@@ -22,7 +22,7 @@ class FormatIdentifier {
'CSV',
'HTML',
'PDF'
);
];
/**
* Construct new format identifier

View File

@@ -5,7 +5,6 @@ use PHPExcel_Cell;
use PHPExcel_Exception;
use PHPExcel_Worksheet;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Config;
use Maatwebsite\Excel\Writers\CellWriter;
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
use PHPExcel_Worksheet_PageSetup;
@@ -46,19 +45,19 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
* Data
* @var array
*/
public $data = array();
public $data = [];
/**
* Merge data
* @var array
*/
public $mergeData = array();
public $mergeData = [];
/**
* Allowed page setup
* @var array
*/
public $allowedPageSetup = array(
public $allowedPageSetup = [
'orientation',
'paperSize',
'scale',
@@ -71,17 +70,17 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
'verticalCentered',
'printArea',
'firstPageNumber'
);
];
/**
* Allowed page setup
* @var array
*/
public $allowedStyles = array(
public $allowedStyles = [
'fontFamily',
'fontSize',
'fontBold'
);
];
/**
* Check if the file was autosized
@@ -112,7 +111,7 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
$this->setParent($pParent);
// check if we should generate headings
// defaults to true if not overridden by settings
$this->autoGenerateHeading = Config::get('excel.export.generate_heading_by_indices', true);
$this->autoGenerateHeading = config('excel.export.generate_heading_by_indices', true);
}
/**
@@ -130,15 +129,15 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
list($setter, $set) = $this->_setSetter($setup);
// get the value
$value = Config::get('excel.sheets.pageSetup.' . $setup, null);
$value = config('excel.sheets.pageSetup.' . $setup, null);
// Set the page setup value
if (!is_null($value))
call_user_func_array(array($pageSetup, $setter), array($value));
call_user_func_array([$pageSetup, $setter], [$value]);
}
// Set default page margins
$this->setPageMargin(Config::get('excel.export.sheets.page_margin', false));
$this->setPageMargin(config('excel.export.sheets.page_margin', false));
}
/**
@@ -149,7 +148,7 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
{
if (!is_array($margin))
{
$marginArray = array($margin, $margin, $margin, $margin);
$marginArray = [$margin, $margin, $margin, $margin];
}
else
{
@@ -225,7 +224,7 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
* @param boolean $explicit
* @return LaravelExcelWorksheet
*/
public function rows($rows = array(), $explicit = false)
public function rows($rows = [], $explicit = false)
{
// Get the start row
$startRow = $this->getStartRow();
@@ -354,7 +353,7 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
*/
public function setView()
{
return call_user_func_array(array($this, 'loadView'), func_get_args());
return call_user_func_array([$this, 'loadView'], func_get_args());
}
/**
@@ -364,7 +363,7 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
* @param array $mergeData
* @return LaravelExcelWorksheet
*/
public function loadView($view, $data = array(), $mergeData = array())
public function loadView($view, $data = [], $mergeData = [])
{
// Init the parser
if (!$this->parser)
@@ -491,47 +490,47 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
*/
public function createSheetFromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false)
{
if (is_array($source))
{
// Convert a 1-D array to 2-D (for ease of looping)
if (!is_array(end($source)))
{
$source = array($source);
}
// start coordinate
list ($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($startCell);
// Loop through $source
foreach ($source as $rowData)
{
$currentColumn = $startColumn;
foreach ($rowData as $cellValue)
{
if ($strictNullComparison)
{
if ($cellValue !== $nullValue)
{
// Set cell value
$this->setValueOfCell($cellValue, $currentColumn, $startRow);
}
}
else
{
if ($cellValue != $nullValue)
{
// Set cell value
$this->setValueOfCell($cellValue, $currentColumn, $startRow);
}
}
++$currentColumn;
}
++$startRow;
}
}
else
{
if (!is_array($source))
throw new PHPExcel_Exception("Parameter \$source should be an array.");
// Convert a 1-D array to 2-D (for ease of looping)
if (!is_array(end($source)))
{
$source = [$source];
}
// start coordinate
list ($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($startCell);
$currentRow = $startRow;
// Loop through $source
foreach ($source as $rowData)
{
if (!is_array($rowData))
throw new PHPExcel_Exception("Row `$rowData` must be array.");
$currentColumn = $startColumn;
foreach ($rowData as $cellValue)
{
if ($strictNullComparison)
{
if ($cellValue !== $nullValue)
{
// Set cell value
$this->setValueOfCell($cellValue, $currentColumn, $currentRow);
}
}
else
{
if ($cellValue != $nullValue)
{
// Set cell value
$this->setValueOfCell($cellValue, $currentColumn, $currentRow);
}
}
$currentColumn++;
}
$currentRow++;
}
return $this;
@@ -580,13 +579,12 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
*/
protected function addData($array)
{
// If a parser was set
if ($this->parser)
{
// Don't change anything
$data = $array;
}
else
// Return empty array
if (empty($array))
return $this->data;
// If a parser wasn't set
if (!$this->parser)
{
// Transform model/collection to array
if ($array instanceof Collection)
@@ -596,22 +594,16 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
$firstRow = reset($array);
// Check if the array has array values
if (count($firstRow) != count($firstRow, 1))
if (is_array($firstRow) && count($firstRow) != count($firstRow, 1))
{
// Loop through the data to remove arrays
$data = array();
$r = 0;
foreach ($array as $row)
$data = [];
foreach ($array as $key1 => &$row)
{
$data[$r] = array();
foreach ($row as $key => $cell)
{
if (!is_array($cell))
{
$data[$r][$key] = $cell;
}
}
$r++;
$data[$key1] = [];
array_walk($row, function($cell, $key2) use ($key1, &$data) {
$data[$key1][$key2] = is_array($cell) ? '': $cell;
});
}
}
else
@@ -635,12 +627,16 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
}
}
}
else
{
$data = $array;
}
// Add results
if (!empty($data))
$this->data = !empty($this->data) ? array_merge($this->data, $data) : $data;
return !empty($this->data) ? array_merge($this->data, $data) : $data;
// return data
// Return data
return $this->data;
}
@@ -693,16 +689,16 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
if (in_array($key, $this->allowedPageSetup))
{
// Set params
$params = is_array($params) ? $params : array($params);
$params = is_array($params) ? $params : [$params];
// Call the setter
return call_user_func_array(array($this->getPageSetup(), $setter), $params);
return call_user_func_array([$this->getPageSetup(), $setter], $params);
}
// If is a style
elseif (in_array($key, $this->allowedStyles))
{
return $this->setDefaultStyles($setter, $key, $params);
return $this->setDefaultStyles($setter, $key, $params);
}
else
{
@@ -720,12 +716,12 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
protected function setDefaultStyles($setter, $key, $params)
{
$caller = $this->getDefaultStyle();
$params = is_array($params) ? $params : array($params);
$params = is_array($params) ? $params : [$params];
if (str_contains($key, 'font'))
return $this->setFontStyle($caller, $setter, $key, $params);
return call_user_func_array(array($caller, $setter), $params);
return call_user_func_array([$caller, $setter], $params);
}
/**
@@ -766,7 +762,7 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
{
// Set caller to font
$caller = $caller->getFont();
$params = is_array($params) ? $params : array($params);
$params = is_array($params) ? $params : [$params];
// Clean the setter name
$setter = lcfirst(str_replace('Font', '', $setter));
@@ -774,7 +770,7 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
// Replace special cases
$setter = str_replace('Family', 'Name', $setter);
return call_user_func_array(array($caller, $setter), $params);
return call_user_func_array([$caller, $setter], $params);
}
/**
@@ -795,7 +791,7 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
}
// Return the setter method and the key
return array($setter, $key);
return [$setter, $key];
}
/**
@@ -957,7 +953,7 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
if (isset($this->autoSize))
return $this->autoSize;
return Config::get('excel.export.autosize', true);
return config('excel.export.autosize', true);
}
/**
@@ -1051,13 +1047,13 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
*/
public function setAllBorders($weight = 'thin')
{
$styleArray = array(
'borders' => array(
'allborders' => array(
$styleArray = [
'borders' => [
'allborders' => [
'style' => $weight
)
)
);
]
]
];
// Apply the style
$this->getDefaultStyle()
@@ -1100,7 +1096,7 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
// Set center alignment on merge cells
$this->cells($pRange, function ($cell) use ($alignment)
{
$aligment = is_string($alignment) ? $alignment : Config::get('excel.export.merged_cell_alignment', 'left');
$aligment = is_string($alignment) ? $alignment : config('excel.export.merged_cell_alignment', 'left');
$cell->setAlignment($aligment);
});
@@ -1173,7 +1169,7 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
*/
protected function getDefaultNullValue()
{
return Config::get('excel.export.sheets.nullValue', null);
return config('excel.export.sheets.nullValue', null);
}
/**
@@ -1182,7 +1178,7 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
*/
protected function getDefaultStartCell()
{
return Config::get('excel.export.sheets.startCell', 'A1');
return config('excel.export.sheets.startCell', 'A1');
}
@@ -1192,7 +1188,7 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
*/
protected function getDefaultStrictNullComparison()
{
return Config::get('excel.export.sheets.strictNullComparison', false);
return config('excel.export.sheets.strictNullComparison', false);
}
/**
@@ -1270,4 +1266,22 @@ class LaravelExcelWorksheet extends PHPExcel_Worksheet {
? $this->getCell($currentColumn . $startRow)->setValueExplicit($cellValue)
: $this->getCell($currentColumn . $startRow)->setValue($cellValue);
}
/**
* Allowed page setup
* @return array
*/
public function getAllowedPageSetup()
{
return $this->allowedPageSetup;
}
/**
* Allowed page setup
* @return array
*/
public function getAllowedStyles()
{
return $this->allowedStyles;
}
}

View File

@@ -1,7 +1,6 @@
<?php namespace Maatwebsite\Excel\Classes;
use PHPExcel as PHPOffice_PHPExcel;
use Illuminate\Support\Facades\Config;
/**
*
@@ -20,7 +19,7 @@ class PHPExcel extends PHPOffice_PHPExcel {
* Allowed autofill properties
* @var array
*/
public $allowedProperties = array(
public $allowedProperties = [
'creator',
'lastModifiedBy',
'description',
@@ -29,7 +28,7 @@ class PHPExcel extends PHPOffice_PHPExcel {
'category',
'manager',
'company'
);
];
/**
* Create sheet and add it to this workbook
@@ -80,10 +79,10 @@ class PHPExcel extends PHPOffice_PHPExcel {
$method = 'set' . ucfirst($prop);
// get the value
$value = in_array($prop, array_keys($custom)) ? $custom[$prop] : Config::get('excel.properties.' . $prop, null);
$value = in_array($prop, array_keys($custom)) ? $custom[$prop] : config('excel.properties.' . $prop, null);
// set the property
call_user_func_array(array($properties, $method), array($value));
call_user_func_array([$properties, $method], [$value]);
}
}

View File

@@ -17,7 +17,7 @@ class CellCollection extends ExcelCollection {
* @param array $items
* @return \Maatwebsite\Excel\Collections\CellCollection
*/
public function __construct(array $items = array())
public function __construct(array $items = [])
{
$this->setItems($items);
}
@@ -29,30 +29,25 @@ class CellCollection extends ExcelCollection {
*/
public function setItems($items)
{
foreach ($items as $name => $value)
{
$value = !empty($value) || is_numeric($value) ? $value : null;
if ($name)
{
$this->put($name, $value);
}
else
{
$this->push($value);
}
foreach ($items as $name => $value) {
$name = trim($name) !== '' && !empty($name) ? $name : null;
$value = !empty($value) || is_numeric($value) || is_bool($value) ? $value : null;
$this->put($name, $value);
}
}
/**
* Dynamically get values
* @param string $key
* @return string
* @return string|null
*/
public function __get($key)
{
if ($this->has($key))
if ($this->has($key)) {
return $this->get($key);
}
return null;
}
/**

View File

@@ -13,4 +13,27 @@
*/
class RowCollection extends ExcelCollection {
}
/**
* Sheet heading
* @var array
*/
protected $heading;
/**
* Get the heading
* @return array
*/
public function getHeading()
{
return $this->heading;
}
/**
* Set the heading
* @param array $heading
*/
public function setHeading(array $heading)
{
$this->heading = $heading;
}
}

View File

@@ -24,10 +24,10 @@ class Excel {
* Filter
* @var array
*/
protected $filters = array(
'registered' => array(),
'enabled' => array()
);
protected $filters = [
'registered' => [],
'enabled' => []
];
/**
* Excel object
@@ -83,7 +83,7 @@ class Excel {
$writer->setTitle($filename);
// Do the callback
if ($callback instanceof Closure)
if (is_callable($callback))
call_user_func($callback, $writer);
// Return the writer object
@@ -97,7 +97,8 @@ class Excel {
* @param string $file The file we want to load
* @param callback|null $callback
* @param string|null $encoding
* @param bool $noBasePath
* @param bool $noBasePath
* @param callback|null $callbackConfigReader
* @return LaravelExcelReader
*/
public function load($file, $callback = null, $encoding = null, $noBasePath = false, $callbackConfigReader = null)
@@ -130,7 +131,7 @@ class Excel {
* @param $sheets
* @return LaravelExcelReader
*/
public function selectSheets($sheets = array())
public function selectSheets($sheets = [])
{
$sheets = is_array($sheets) ? $sheets : func_get_args();
$this->reader->setSelectedSheets($sheets);
@@ -143,7 +144,7 @@ class Excel {
* @param array $sheets
* @return $this
*/
public function selectSheetsByIndex($sheets = array())
public function selectSheetsByIndex($sheets = [])
{
$sheets = is_array($sheets) ? $sheets : func_get_args();
$this->reader->setSelectedSheetIndices($sheets);
@@ -171,7 +172,7 @@ class Excel {
* @param array $mergeData
* @return LaravelExcelWriter
*/
public function shareView($view, $data = array(), $mergeData = array())
public function shareView($view, $data = [], $mergeData = [])
{
return $this->create($view)->shareView($view, $data, $mergeData);
}
@@ -183,7 +184,7 @@ class Excel {
* @param array $mergeData
* @return LaravelExcelWriter
*/
public function loadView($view, $data = array(), $mergeData = array())
public function loadView($view, $data = [], $mergeData = [])
{
return $this->shareView($view, $data, $mergeData);
}
@@ -193,7 +194,7 @@ class Excel {
* @param array $filters
* @return Excel
*/
public function registerFilters($filters = array())
public function registerFilters($filters = [])
{
// If enabled array key exists
if(array_key_exists('enabled', $filters))
@@ -263,14 +264,14 @@ class Excel {
if (method_exists($this->excel, $method))
{
// Call the method from the excel object with the given params
return call_user_func_array(array($this->excel, $method), $params);
return call_user_func_array([$this->excel, $method], $params);
}
// If reader method exists, call that one
if (method_exists($this->reader, $method))
{
// Call the method from the reader object with the given params
return call_user_func_array(array($this->reader, $method), $params);
return call_user_func_array([$this->reader, $method], $params);
}
throw new LaravelExcelException('Laravel Excel method [' . $method . '] does not exist');

View File

@@ -4,9 +4,9 @@ use PHPExcel_Settings;
use PHPExcel_Shared_Font;
use Maatwebsite\Excel\Readers\Html;
use Maatwebsite\Excel\Classes\Cache;
use Illuminate\Support\Facades\Config;
use Maatwebsite\Excel\Classes\PHPExcel;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Response;
use Maatwebsite\Excel\Parsers\CssParser;
use Maatwebsite\Excel\Parsers\ViewParser;
@@ -14,6 +14,7 @@ use Maatwebsite\Excel\Classes\FormatIdentifier;
use Maatwebsite\Excel\Readers\LaravelExcelReader;
use Maatwebsite\Excel\Writers\LaravelExcelWriter;
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
use Laravel\Lumen\Application as LumenApplication;
/**
*
@@ -42,9 +43,13 @@ class ExcelServiceProvider extends ServiceProvider {
public function boot()
{
$this->publishes([
__DIR__ . '/../../config/excel.php' => config_path('excel.php'),
]);
if ($this->app instanceof LumenApplication) {
$this->app->configure('excel');
} else {
$this->publishes([
__DIR__ . '/../../config/excel.php' => config_path('excel.php'),
]);
}
$this->mergeConfigFrom(
__DIR__ . '/../../config/excel.php', 'excel'
@@ -52,6 +57,18 @@ class ExcelServiceProvider extends ServiceProvider {
//Set the autosizing settings
$this->setAutoSizingSettings();
//Enable an "export" method on Eloquent collections. ie: model::all()->export('file');
if (method_exists(Collection::class, 'macro')) {
Collection::macro('export', function($filename, $type = 'xlsx', $method = 'download') {
$model = $this;
Facades\Excel::create($filename, function($excel) use ($model, $filename) {
$excel->sheet($filename, function($sheet) use ($model) {
$sheet->fromModel($model);
});
})->$method($type);
});
}
}
/**
@@ -80,7 +97,7 @@ class ExcelServiceProvider extends ServiceProvider {
$me = $this;
// Bind the PHPExcel class
$this->app['phpexcel'] = $this->app->share(function () use ($me)
$this->app->singleton('phpexcel', function () use ($me)
{
// Set locale
$me->setLocale();
@@ -93,6 +110,8 @@ class ExcelServiceProvider extends ServiceProvider {
$excel->setDefaultProperties();
return $excel;
});
$this->app->alias('phpexcel', PHPExcel::class);
}
/**
@@ -101,7 +120,7 @@ class ExcelServiceProvider extends ServiceProvider {
protected function bindCssParser()
{
// Bind css parser
$this->app['excel.parsers.css'] = $this->app->share(function ()
$this->app->singleton('excel.parsers.css', function ()
{
return new CssParser(
new CssToInlineStyles()
@@ -116,7 +135,7 @@ class ExcelServiceProvider extends ServiceProvider {
protected function bindReaders()
{
// Bind the laravel excel reader
$this->app['excel.reader'] = $this->app->share(function ($app)
$this->app->singleton('excel.reader', function ($app)
{
return new LaravelExcelReader(
$app['files'],
@@ -126,7 +145,7 @@ class ExcelServiceProvider extends ServiceProvider {
});
// Bind the html reader class
$this->app['excel.readers.html'] = $this->app->share(function ($app)
$this->app->singleton('excel.readers.html', function ($app)
{
return new Html(
$app['excel.parsers.css']
@@ -141,7 +160,7 @@ class ExcelServiceProvider extends ServiceProvider {
protected function bindParsers()
{
// Bind the view parser
$this->app['excel.parsers.view'] = $this->app->share(function ($app)
$this->app->singleton('excel.parsers.view', function ($app)
{
return new ViewParser(
$app['excel.readers.html']
@@ -156,7 +175,7 @@ class ExcelServiceProvider extends ServiceProvider {
protected function bindWriters()
{
// Bind the excel writer
$this->app['excel.writer'] = $this->app->share(function ($app)
$this->app->singleton('excel.writer', function ($app)
{
return new LaravelExcelWriter(
$app->make(Response::class),
@@ -173,7 +192,7 @@ class ExcelServiceProvider extends ServiceProvider {
protected function bindExcel()
{
// Bind the Excel class and inject its dependencies
$this->app['excel'] = $this->app->share(function ($app)
$this->app->singleton('excel', function ($app)
{
$excel = new Excel(
$app['phpexcel'],
@@ -186,8 +205,8 @@ class ExcelServiceProvider extends ServiceProvider {
return $excel;
});
$this->app->alias('phpexcel', PHPExcel::class);
$this->app->alias('excel', Excel::class);
}
/**
@@ -197,7 +216,7 @@ class ExcelServiceProvider extends ServiceProvider {
protected function bindClasses()
{
// Bind the format identifier
$this->app['excel.identifier'] = $this->app->share(function ($app)
$this->app->singleton('excel.identifier', function ($app)
{
return new FormatIdentifier($app['files']);
});
@@ -217,7 +236,7 @@ class ExcelServiceProvider extends ServiceProvider {
*/
public function setLocale()
{
$locale = Config::get('app.locale', 'en_us');
$locale = config('app.locale', 'en_us');
PHPExcel_Settings::setLocale($locale);
}
@@ -226,7 +245,7 @@ class ExcelServiceProvider extends ServiceProvider {
*/
public function setAutoSizingSettings()
{
$method = Config::get('excel.export.autosize-method', PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX);
$method = config('excel.export.autosize-method', PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX);
PHPExcel_Shared_Font::setAutoSizeMethod($method);
}
@@ -237,13 +256,13 @@ class ExcelServiceProvider extends ServiceProvider {
*/
public function provides()
{
return array(
return [
'excel',
'phpexcel',
'excel.reader',
'excel.readers.html',
'excel.parsers.view',
'excel.writer'
);
];
}
}

View File

@@ -33,14 +33,11 @@ class ChunkReadFilter implements PHPExcel_Reader_IReadFilter
* @param string $column
* @param integer $row
* @param string $worksheetName
* @return booleaan
* @return boolean
*/
public function readCell($column, $row, $worksheetName = '')
{
// Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
if (($row == config('excel.import.startRow')) || ($row >= $this->_startRow && $row <= $this->_endRow)) {
return true;
}
return false;
return ($row == config('excel.import.startRow')) || ($row >= $this->_startRow && $row <= $this->_endRow);
}
}

View File

@@ -32,7 +32,7 @@ class CssParser {
* Style sheet links
* @var array
*/
protected $links = array();
protected $links = [];
/**
* Construct the css parser
@@ -48,23 +48,15 @@ class CssParser {
*/
public function transformCssToInlineStyles($html)
{
// Clean-up html
$this->cssInliner->setCleanup(true);
// Set html
$this->cssInliner->setHtml($html);
// Use inline style blocks
$this->cssInliner->setUseInlineStylesBlock(true);
$css = '';
// Loop through all stylesheets
foreach($this->links as $link)
{
$css = file_get_contents($link);
$this->cssInliner->setCSS($css);
$css .= file_get_contents($link);
}
return $this->cssInliner->convert();
return $this->cssInliner->convert($html, $css);
}
/**

View File

@@ -1,12 +1,14 @@
<?php namespace Maatwebsite\Excel\Parsers;
use Carbon\Carbon;
use Maatwebsite\Excel\Classes\LaravelExcelWorksheet;
use Maatwebsite\Excel\Classes\PHPExcel;
use Maatwebsite\Excel\Readers\LaravelExcelReader;
use PHPExcel_Cell;
use PHPExcel_Exception;
use PHPExcel_Shared_Date;
use Illuminate\Support\Str;
use PHPExcel_Style_NumberFormat;
use Illuminate\Support\Facades\Config;
use Maatwebsite\Excel\Collections\RowCollection;
use Maatwebsite\Excel\Collections\CellCollection;
use Maatwebsite\Excel\Collections\SheetCollection;
@@ -51,7 +53,7 @@ class ExcelParser {
/**
* Row object
* @var PHPExcel_Worksheet_Row
* @var \PHPExcel_Worksheet_Row
*/
protected $row;
@@ -71,7 +73,7 @@ class ExcelParser {
* Columns we want to fetch
* @var array
*/
protected $columns = array();
protected $columns = [];
/**
* Row counter
@@ -86,16 +88,14 @@ class ExcelParser {
protected $defaultStartRow = 1;
/**
* Construct excel parser
* @param LaravelExcelReader $reader
* @return \Maatwebsite\Excel\Parsers\ExcelParser
*/
public function __construct($reader)
{
$this->reader = $reader;
$this->excel = $reader->excel;
$this->defaultStartRow = $this->currentRow = Config::get('excel.import.startRow', 1);
$this->defaultStartRow = $this->currentRow = $reader->getHeaderRow();
// Reset
$this->reset();
@@ -106,7 +106,7 @@ class ExcelParser {
* @param array $columns
* @return SheetCollection
*/
public function parseFile($columns = array())
public function parseFile($columns = [])
{
// Init new sheet collection
$workbook = new SheetCollection();
@@ -164,7 +164,7 @@ class ExcelParser {
protected function parseAsMultiple()
{
return ($this->excel->getSheetCount() > 1 && count($this->reader->getSelectedSheetIndices()) !== 1)
|| Config::get('excel.import.force_sheets_collection', false);
|| config('excel.import.force_sheets_collection', false);
}
/**
@@ -177,7 +177,7 @@ class ExcelParser {
$this->excel->setActiveSheetIndex($this->w);
// Fetch the labels
$this->indices = $this->reader->hasHeading() ? $this->getIndices() : array();
$this->indices = $this->reader->hasHeading() ? $this->getIndices() : [];
// Parse the rows
return $this->parseRows();
@@ -193,11 +193,10 @@ class ExcelParser {
$this->row = $this->worksheet->getRowIterator($this->defaultStartRow)->current();
// Set empty labels array
$this->indices = array();
$this->indices = [];
// Loop through the cells
foreach ($this->row->getCellIterator() as $this->cell)
{
foreach ($this->row->getCellIterator() as $this->cell) {
$this->indices[] = $this->getIndex($this->cell);
}
@@ -213,7 +212,7 @@ class ExcelParser {
protected function getIndex($cell)
{
// Get heading type
$config = Config::get('excel.import.heading', true);
$config = config('excel.import.heading', true);
$config = $config === true ? 'slugged' : $config;
// Get value
@@ -222,10 +221,10 @@ class ExcelParser {
switch ($config)
{
case 'slugged':
return $this->getSluggedIndex($value, Config::get('excel.import.to_ascii', true));
return $this->getSluggedIndex($value, config('excel.import.to_ascii', true));
break;
case 'slugged_with_count':
$index = $this->getSluggedIndex($value, Config::get('excel.import.to_ascii', true));
$index = $this->getSluggedIndex($value, config('excel.import.to_ascii', true));
if(in_array($index,$this->indices)){
$index = $this->appendOrIncreaseStringCount($index);
}
@@ -240,6 +239,10 @@ class ExcelParser {
return $this->getHashedIndex($value);
break;
case 'hashed_with_lower':
return $this->getHashedIndex(strtolower(trim($value)));
break;
case 'trans':
return $this->getTranslatedIndex($value);
break;
@@ -296,7 +299,7 @@ class ExcelParser {
$value = preg_replace('![' . preg_quote($flip) . ']+!u', $separator, $value);
// Remove all characters that are not the separator, letters, numbers, or whitespace.
$value = preg_replace('![^' . preg_quote($separator) . '\pL\pN\s]+!u', '', mb_strtolower($value));
$value = preg_replace('![^' . preg_quote(config('excel.import.slug_whitelist', $separator)) . '\pL\pN\s]+!u', '', mb_strtolower($value));
// Replace all separator characters and whitespace by a single separator
$value = preg_replace('![' . preg_quote($separator) . '\s]+!u', $separator, $value);
@@ -356,6 +359,9 @@ class ExcelParser {
// set sheet title
$parsedRows->setTitle($this->excel->getActiveSheet()->getTitle());
// set sheet heading
$parsedRows->setHeading($this->indices);
// Get the start row
$startRow = $this->getStartRow();
@@ -369,7 +375,7 @@ class ExcelParser {
foreach ($rows as $this->row)
{
// Limit the results when needed
if ( $this->hasReachedLimit() )
if ( $this->hasReachedLimitRows() )
break;
// Push the parsed cells inside the parsed rows
@@ -408,16 +414,16 @@ class ExcelParser {
}
/**
* Check for the limit
* Check for the row limit
* @return boolean
*/
protected function hasReachedLimit()
protected function hasReachedLimitRows()
{
// Get skip
$limit = $this->reader->getLimit();
$rowsLimit = $this->reader->getLimitRows();
// If we have a limit, check if we hit this limit
return $limit && $this->currentRow > $limit ? true : false;
return $rowsLimit && $this->currentRow > $rowsLimit ? true : false;
}
/**
@@ -426,12 +432,17 @@ class ExcelParser {
*/
protected function parseCells()
{
$i = 0;
$parsedCells = array();
// Skip the columns when needed
$startColumn = $this->reader->getTargetSkipColumns();
// Limit the columns when needed
$endColumn = $this->reader->getTargetLimitColumns();
try {
// Set the cell iterator
$cellIterator = $this->row->getCellIterator();
$cellIterator = $this->row->getCellIterator($startColumn, $endColumn);
// Ignore empty cells if needed
$cellIterator->setIterateOnlyExistingCells($this->reader->needsIgnoreEmpty());
@@ -440,16 +451,18 @@ class ExcelParser {
foreach ($cellIterator as $this->cell)
{
// Check how we need to save the parsed array
$index = ($this->reader->hasHeading() && isset($this->indices[$i])) ? $this->indices[$i] : $this->getIndexFromColumn();
// Use the index from column as the initial position
// Or else PHPExcel skips empty cells (even between non-empty) cells and it will cause
// data to end up in the result object
$index = $this->getIndexFromColumn() - 1;
$index = ($this->reader->hasHeading() && isset($this->indices[$index])) ? $this->indices[$index] : $index;
// Check if we want to select this column
if ( $this->cellNeedsParsing($index) )
{
// Set the value
// Set the value1
$parsedCells[(string) $index] = $this->parseCell($index);
}
$i++;
}
} catch (PHPExcel_Exception $e) {
@@ -458,11 +471,18 @@ class ExcelParser {
throw $e;
}
// make sure that we return an empty CellCollection
$parsedCells = array();
$parsedCells = [];
}
// Return array with parsed cells
return new CellCollection($parsedCells);
$cells = new CellCollection($parsedCells);
if (! $this->reader->hasHeading()) {
// Cell index starts at 0 when no heading
return $cells->values();
}
return $cells;
}
/**
@@ -522,7 +542,7 @@ class ExcelParser {
protected function encode($value)
{
// Get input and output encoding
list($input, $output) = array_values(Config::get('excel.import.encoding', array('UTF-8', 'UTF-8')));
list($input, $output) = array_values(config('excel.import.encoding', array('UTF-8', 'UTF-8')));
// If they are the same, return the value
if ( $input == $output )
@@ -560,8 +580,15 @@ class ExcelParser {
// If has a date
if ( $cellContent = $this->cell->getCalculatedValue() )
{
// Convert excel time to php date object
$date = PHPExcel_Shared_Date::ExcelToPHPObject($this->cell->getCalculatedValue())->format('Y-m-d H:i:s');
try
{
// Convert excel time to php date object
$date = PHPExcel_Shared_Date::ExcelToPHPObject($this->cell->getCalculatedValue())->format('Y-m-d H:i:s');
}
catch( \ErrorException $ex )
{
return null ;
}
// Parse with carbon
$date = Carbon::parse($date);
@@ -661,7 +688,7 @@ class ExcelParser {
*/
protected function reset()
{
$this->indices = array();
$this->indices = [];
$this->isParsed = false;
}
}

View File

@@ -26,13 +26,13 @@ class ViewParser {
* Data array
* @var array
*/
public $data = array();
public $data = [];
/**
* View merge data
* @var array
*/
public $mergeData = array();
public $mergeData = [];
/**
* Construct the view parser
@@ -108,7 +108,7 @@ class ViewParser {
* Set the data
* @param array $data
*/
public function setData($data = array())
public function setData($data = [])
{
if (!empty($data))
$this->data = array_merge($this->data, $data);
@@ -118,7 +118,7 @@ class ViewParser {
* Set the merge data
* @param array $mergeData
*/
public function setMergeData($mergeData = array())
public function setMergeData($mergeData = [])
{
if (!empty($mergeData))
$this->mergeData = array_merge($this->mergeData, $mergeData);

View File

@@ -27,17 +27,17 @@ class Batch {
* Batch files
* @var array
*/
public $files = array();
public $files = [];
/**
* Set allowed file extensions
* @var array
*/
protected $allowedFileExtensions = array(
protected $allowedFileExtensions = [
'xls',
'xlsx',
'csv'
);
];
/**
* Start the Batach
@@ -112,7 +112,7 @@ class Batch {
*/
protected function _getFilesByArray($array)
{
$files = array();
$files = [];
// Make sure we have real paths
foreach ($array as $i => $file)
{
@@ -137,7 +137,7 @@ class Batch {
$glob = glob($folder . '/*.{' . implode(',', $this->allowedFileExtensions) . '}', GLOB_BRACE);
// If no matches, return empty array
if ($glob === false) return array();
if ($glob === false) return [];
// Return files
return array_filter($glob, function ($file)

View File

@@ -2,12 +2,15 @@
namespace Maatwebsite\Excel\Readers;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Maatwebsite\Excel\Filters\ChunkReadFilter;
use SuperClosure\Serializer;
class ChunkedReadJob implements ShouldQueue
{
use Queueable;
/**
* @var int
*/
@@ -42,17 +45,23 @@ class ChunkedReadJob implements ShouldQueue
* @var bool
*/
private $shouldQueue;
/**
* @var string|null
*/
private $encoding;
/**
* ChunkedReadJob constructor.
*
* @param $file
* @param null $sheets
* @param int $startRow
* @param $startIndex
* @param $chunkSize
* @param callable $callback
* @param bool $shouldQueue
* @param $file
* @param null $sheets
* @param int $startRow
* @param $startIndex
* @param $chunkSize
* @param callable $callback
* @param bool $shouldQueue
* @param string|null $encoding
*/
public function __construct(
$file,
@@ -61,7 +70,8 @@ class ChunkedReadJob implements ShouldQueue
$startIndex,
$chunkSize,
callable $callback,
$shouldQueue = true
$shouldQueue = true,
$encoding = null
) {
$this->startRow = $startRow;
$this->chunkSize = $chunkSize;
@@ -71,6 +81,7 @@ class ChunkedReadJob implements ShouldQueue
$this->callback = $shouldQueue ? (new Serializer)->serialize($callback) : $callback;
$this->sheets = $sheets;
$this->shouldQueue = $shouldQueue;
$this->encoding = $encoding;
}
/***
@@ -86,6 +97,11 @@ class ChunkedReadJob implements ShouldQueue
$reader->reader->setLoadSheetsOnly($this->sheets);
$reader->reader->setReadFilter($filter);
$reader->reader->setReadDataOnly(true);
// Set encoding
if (! is_null($this->encoding)) {
$reader->reader->setInputEncoding($this->encoding);
}
// Set the rows for the chunking
$filter->setRows($this->startRow, $this->chunkSize);
@@ -94,7 +110,7 @@ class ChunkedReadJob implements ShouldQueue
$reader->excel = $reader->reader->load($this->file);
// Slice the results
$results = $reader->get()->slice($this->startIndex, $this->chunkSize);
$results = $reader->limitRows($this->chunkSize, $this->startIndex)->get();
$callback = $this->shouldQueue ? (new Serializer)->unserialize($this->callback) : $this->callback;

View File

@@ -3,7 +3,6 @@
use Closure;
use PHPExcel;
use Maatwebsite\Excel\Excel;
use Illuminate\Support\Facades\Config;
use Maatwebsite\Excel\Collections\SheetCollection;
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
@@ -161,7 +160,7 @@ class ConfigReader {
*/
protected function getCoordinateByKey($field)
{
return Config::get($this->configName . '.' . $this->sheetName . '.' . $field, false);
return config($this->configName . '.' . $this->sheetName . '.' . $field, false);
}
/**

View File

@@ -14,7 +14,6 @@ use PHPExcel_Style_Font;
use PHPExcel_Style_Border;
use PHPExcel_Worksheet_Drawing;
use PHPExcel_Style_Alignment;
use Illuminate\Support\Facades\Config;
use Maatwebsite\Excel\Parsers\CssParser;
use Maatwebsite\Excel\Classes\LaravelExcelWorksheet;
@@ -36,11 +35,11 @@ class Html extends PHPExcel_Reader_HTML {
* Style per range
* @var array
*/
protected $styles = array();
protected $styles = [];
protected $_dataArray = array();
protected $_dataArray = [];
protected $_nestedColumn = array('A');
protected $_nestedColumn = ['A'];
/**
* @var int
@@ -63,7 +62,7 @@ class Html extends PHPExcel_Reader_HTML {
* HTML tags formatting settings
* @var array
*/
protected $_formats = array();
protected $_formats = [];
/**
* The current colspan
@@ -127,7 +126,7 @@ class Html extends PHPExcel_Reader_HTML {
*/
protected function setStyleFormats()
{
$this->_formats = Config::get('excel.views.styles', array());
$this->_formats = config('excel.views.styles', []);
}
/**
@@ -273,7 +272,7 @@ class Html extends PHPExcel_Reader_HTML {
// If is a dom element
elseif ( $child instanceof DOMElement )
{
$attributeArray = array();
$attributeArray = [];
// Set row (=parent) styles
if ( isset($this->styles[$row]) )
@@ -744,7 +743,7 @@ class Html extends PHPExcel_Reader_HTML {
protected function insertImageBySrc($sheet, $column, $row, $attributes)
{
// Get attributes
$src = $attributes->getAttribute('src');
$src = urldecode($attributes->getAttribute('src'));
$width = (float) $attributes->getAttribute('width');
$height = (float) $attributes->getAttribute('height');
$alt = $attributes->getAttribute('alt');
@@ -758,7 +757,7 @@ class Html extends PHPExcel_Reader_HTML {
$drawing->setWorksheet($sheet);
$drawing->setCoordinates($column . $row);
$drawing->setResizeProportional();
$drawing->setOffsetX($drawing->getWidth() - $drawing->getWidth() / 5);
$drawing->setOffsetX(0);
$drawing->setOffsetY(10);
// Set height and width
@@ -769,8 +768,8 @@ class Html extends PHPExcel_Reader_HTML {
$drawing->setHeight($height);
// Set cell width based on image
$this->parseWidth($sheet, $column, $row, $drawing->getWidth() / 3);
$this->parseHeight($sheet, $column, $row, $drawing->getHeight());
$this->parseWidth($sheet, $column, $row, $drawing->getWidth() / 6);
$this->parseHeight($sheet, $column, $row, $drawing->getHeight() * 0.9);
}
/**
@@ -921,7 +920,7 @@ class Html extends PHPExcel_Reader_HTML {
if ( $horizontal )
$cells->getAlignment()->applyFromArray(
array('horizontal' => $horizontal)
['horizontal' => $horizontal]
);
}
@@ -960,7 +959,7 @@ class Html extends PHPExcel_Reader_HTML {
if ( $vertical )
$cells->getAlignment()->applyFromArray(
array('vertical' => $vertical)
['vertical' => $vertical]
);
}
@@ -988,7 +987,7 @@ class Html extends PHPExcel_Reader_HTML {
* @param array @styles
* @return void
*/
protected function parseCssAttributes($sheet, $column, $row, $styles = array())
protected function parseCssAttributes($sheet, $column, $row, $styles = [])
{
foreach ($styles as $tag)
{
@@ -1033,10 +1032,10 @@ class Html extends PHPExcel_Reader_HTML {
$value = $this->getColor($value);
$cells->getFill()->applyFromArray(
array(
[
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb' => $value)
)
'color' => ['rgb' => $value]
]
);
break;
@@ -1045,7 +1044,7 @@ class Html extends PHPExcel_Reader_HTML {
case 'color':
$value = $this->getColor($value);
$cells->getFont()->getColor()->applyFromArray(
array('rgb' => $value)
['rgb' => $value]
);
break;
@@ -1069,7 +1068,7 @@ class Html extends PHPExcel_Reader_HTML {
// FONT FACE
case 'font-family':
$cells->getFont()->applyFromArray(
array('name' => $value)
['name' => $value]
);
break;
@@ -1113,7 +1112,7 @@ class Html extends PHPExcel_Reader_HTML {
if ( $horizontal )
$cells->getAlignment()->applyFromArray(
array('horizontal' => $horizontal)
['horizontal' => $horizontal]
);
break;
@@ -1144,7 +1143,7 @@ class Html extends PHPExcel_Reader_HTML {
if ( $vertical )
$cells->getAlignment()->applyFromArray(
array('vertical' => $vertical)
['vertical' => $vertical]
);
break;
@@ -1152,67 +1151,77 @@ class Html extends PHPExcel_Reader_HTML {
case 'border':
case 'borders':
$borders = explode(' ', $value);
$style = $borders[1];
$color = end($borders);
$color = $this->getColor($color);
$borderStyle = $this->borderStyle($style);
if (!empty($borders[1])) {
$style = $borders[1];
$color = end($borders);
$color = $this->getColor($color);
$borderStyle = $this->borderStyle($style);
$cells->getBorders()->applyFromArray(
array('allborders' => array('style' => $borderStyle, 'color' => array('rgb' => $color)))
);
$cells->getBorders()->applyFromArray(
['allborders' => ['style' => $borderStyle, 'color' => ['rgb' => $color]]]
);
}
break;
// Border-top
case 'border-top':
$borders = explode(' ', $value);
$style = $borders[1];
$color = end($borders);
$color = $this->getColor($color);
if (!empty($borders[1])) {
$style = $borders[1];
$color = end($borders);
$color = $this->getColor($color);
$borderStyle = $this->borderStyle($style);
$borderStyle = $this->borderStyle($style);
$cells->getBorders()->getTop()->applyFromArray(
array('style' => $borderStyle, 'color' => array('rgb' => $color))
);
$cells->getBorders()->getTop()->applyFromArray(
['style' => $borderStyle, 'color' => ['rgb' => $color]]
);
}
break;
// Border-bottom
case 'border-bottom':
$borders = explode(' ', $value);
$style = $borders[1];
$color = end($borders);
$color = $this->getColor($color);
$borderStyle = $this->borderStyle($style);
if (!empty($borders[1])) {
$style = $borders[1];
$color = end($borders);
$color = $this->getColor($color);
$borderStyle = $this->borderStyle($style);
$cells->getBorders()->getBottom()->applyFromArray(
array('style' => $borderStyle, 'color' => array('rgb' => $color))
);
$cells->getBorders()->getBottom()->applyFromArray(
['style' => $borderStyle, 'color' => ['rgb' => $color]]
);
}
break;
// Border-right
case 'border-right':
$borders = explode(' ', $value);
$style = $borders[1];
$color = end($borders);
$color = $this->getColor($color);
$borderStyle = $this->borderStyle($style);
if (!empty($borders[1])) {
$style = $borders[1];
$color = end($borders);
$color = $this->getColor($color);
$borderStyle = $this->borderStyle($style);
$cells->getBorders()->getRight()->applyFromArray(
array('style' => $borderStyle, 'color' => array('rgb' => $color))
);
$cells->getBorders()->getRight()->applyFromArray(
['style' => $borderStyle, 'color' => ['rgb' => $color]]
);
}
break;
// Border-left
case 'border-left':
$borders = explode(' ', $value);
$style = $borders[1];
$color = end($borders);
$color = $this->getColor($color);
$borderStyle = $this->borderStyle($style);
if (!empty($borders[1])) {
$style = $borders[1];
$color = end($borders);
$color = $this->getColor($color);
$borderStyle = $this->borderStyle($style);
$cells->getBorders()->getLeft()->applyFromArray(
array('style' => $borderStyle, 'color' => array('rgb' => $color))
);
$cells->getBorders()->getLeft()->applyFromArray(
['style' => $borderStyle, 'color' => ['rgb' => $color]]
);
}
break;
// wrap-text
@@ -1362,6 +1371,6 @@ class Html extends PHPExcel_Reader_HTML {
}
}
return array($column, $cellContent);
return [$column, $cellContent];
}
}

View File

@@ -1,7 +1,6 @@
<?php namespace Maatwebsite\Excel\Readers;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Config;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Support\Facades\Queue;
use Maatwebsite\Excel\Classes\PHPExcel;
@@ -97,18 +96,39 @@ class LaravelExcelReader
public $calculate;
/**
* Limit data
* Limit of rows
*
* @var boolean
*/
protected $limit = false;
protected $limitRows = false;
/**
* Amount of rows to skip
*
* @var integer
*/
protected $skip = 0;
protected $skipRows = 0;
/**
* Target columns
*
* @var array
*/
protected $targetColumns = [];
/**
* Limit of columns
*
* @var boolean
*/
protected $limitColumns = false;
/**
* Amount of columns to skip
*
* @var integer
*/
protected $skipColumns = 0;
/**
* Slug separator
@@ -226,6 +246,13 @@ class LaravelExcelReader
*/
protected $dispatcher;
/**
* The line containing the header title, by default
*
* @var int
*/
protected $headerRow;
/**
* Construct new reader
*
@@ -351,6 +378,15 @@ class LaravelExcelReader
$this->selectedSheets = $sheets;
}
/**
* Define a different header row than the global config
* @param int $number
*/
public function setHeaderRow($number)
{
$this->headerRow = $number;
}
/**
* Check if sheets were selected
*
@@ -375,7 +411,7 @@ class LaravelExcelReader
return true;
}
return in_array($index, $selectedSheets) ? true : false;
return in_array($index, $selectedSheets);
}
/**
@@ -442,7 +478,20 @@ class LaravelExcelReader
public function take($amount)
{
// Set limit
$this->limit = $amount;
return $this->takeRows($amount);
}
/**
* Take x rows
*
* @param integer $amount
*
* @return LaravelExcelReader
*/
public function takeRows($amount)
{
// Set limit
$this->limitRows = $amount;
return $this;
}
@@ -457,7 +506,20 @@ class LaravelExcelReader
public function skip($amount)
{
// Set skip amount
$this->skip = $amount;
return $this->skipRows($amount);
}
/**
* Skip x rows
*
* @param integer $amount
*
* @return LaravelExcelReader
*/
public function skipRows($amount)
{
// Set skip amount
$this->skipRows = $amount;
return $this;
}
@@ -471,12 +533,75 @@ class LaravelExcelReader
* @return LaravelExcelReader
*/
public function limit($take, $skip = 0)
{
// Limit the results by x
return $this->limitRows($take, $skip);
}
/**
* Limit the results by x
*
* @param integer $take
* @param integer $skip
*
* @return LaravelExcelReader
*/
public function limitRows($take, $skip = 0)
{
// Skip x records
$this->skip($skip);
$this->skipRows($skip);
// Take x records
$this->take($take);
$this->takeRows($take);
return $this;
}
/**
* Take x columns
*
* @param integer $amount
*
* @return LaravelExcelReader
*/
public function takeColumns($amount)
{
// Set limit
$this->limitColumns = $amount;
return $this;
}
/**
* Skip x columns
*
* @param integer $amount
*
* @return LaravelExcelReader
*/
public function skipColumns($amount)
{
// Set skip amount
$this->skipColumns = $amount;
return $this;
}
/**
* Limit the results by x
*
* @param integer $take
* @param integer $skip
*
* @return LaravelExcelReader
*/
public function limitColumns($take, $skip = 0)
{
// Skip x records
$this->skipColumns($skip);
// Take x records
$this->takeColumns($take);
return $this;
}
@@ -516,7 +641,7 @@ class LaravelExcelReader
*/
public function first($columns = [])
{
return $this->take(1)->get($columns)->first();
return $this->get($columns)->first();
}
/**
@@ -546,9 +671,9 @@ class LaravelExcelReader
/**
* Parse the file in chunks and queues the processing of each chunk
*
* @param int $size
* @param callable $callback
* @param bool $shouldQueue
* @param int $size
* @param callable $callback
* @param bool|string $shouldQueue
*/
public function chunk($size = 10, callable $callback, $shouldQueue = true)
{
@@ -560,8 +685,14 @@ class LaravelExcelReader
for ($startRow = 0; $startRow < $totalRows; $startRow += $chunkSize) {
// Set start index
$startIndex = ($startRow == 0) ? $startRow : $startRow - 1;
$chunkSize = ($startRow == 0) ? $size + 1 : $size;
$startIndex = ($startRow == 0 || !$this->hasHeading()) ? $startRow : $startRow - 1;
$chunkSize = ($startRow == 0 && $this->hasHeading()) ? $size + 1 : $size;
$encoding = null;
if ($this->format == 'CSV') {
$encoding = $this->reader->getInputEncoding($encoding);
}
$job = new ChunkedReadJob(
$this->file,
@@ -570,10 +701,15 @@ class LaravelExcelReader
$startIndex,
$chunkSize,
$callback,
$shouldQueue
$shouldQueue,
$encoding
);
if ($shouldQueue) {
// If a string is passed (which also evaluates to true if not empty), assign to that named queue
if(is_string($shouldQueue)) {
$job->onQueue($shouldQueue);
}
$this->dispatcher->dispatch($job);
} else {
$break = $job->handle();
@@ -736,7 +872,7 @@ class LaravelExcelReader
protected function _setFile($file, $noBasePath = false)
{
// check if we have a correct path
if (!$noBasePath && !realpath($file)) {
if (!is_file($file) && !$noBasePath && !realpath($file)) {
$file = base_path($file);
}
@@ -903,7 +1039,7 @@ class LaravelExcelReader
*
* @param boolean $boolean
*
* @return LaraveExcelReader
* @return LaravelExcelReader
*/
public function ignoreEmpty($boolean = true)
{
@@ -920,7 +1056,7 @@ class LaravelExcelReader
public function hasHeading()
{
if (!$this->noHeading) {
$config = Config::get('excel.import.heading', true);
$config = config('excel.import.heading', true);
return $config !== false && $config !== 'numeric';
}
@@ -939,7 +1075,7 @@ class LaravelExcelReader
return $this->separator;
}
return Config::get('excel.import.separator', Config::get('excel.import.seperator', '_'));
return config('excel.import.separator', config('excel.import.seperator', '_'));
}
/**
@@ -999,7 +1135,17 @@ class LaravelExcelReader
*/
public function getSkip()
{
return $this->skip;
return $this->getSkipRows();
}
/**
* Return the amount of rows to skip
*
* @return integer
*/
public function getSkipRows()
{
return $this->skipRows;
}
/**
@@ -1009,7 +1155,88 @@ class LaravelExcelReader
*/
public function getLimit()
{
return $this->limit;
return $this->getLimitRows();
}
/**
* Return the amount of rows to take
*
* @return integer
*/
public function getLimitRows()
{
return $this->limitRows;
}
/**
* Return the amount of columns to skip
*
* @return integer
*/
public function getSkipColumns()
{
return $this->skipColumns;
}
/**
* Return the target of columns to skip
*
* @return string
*/
public function getTargetSkipColumns()
{
if (empty($this->skipColumns)) {
return 'A';
}
$columns = $this->getTargetColumns();
return $columns[$this->skipColumns];
}
/**
* Return the target columns
*
* @return array
*/
private function getTargetColumns()
{
if (!empty($this->targetColumns)) {
return $this->targetColumns;
}
$this->targetColumns = [];
for ($letter = 'A'; $letter <= 'ZZZ'; $letter++) {
$this->targetColumns[] = $letter;
}
return $this->targetColumns;
}
/**
* Return the amount of columns to take
*
* @return integer
*/
public function getLimitColumns()
{
return $this->limitColumns;
}
/**
* Return the target of columns to take
*
* @return string
*/
public function getTargetLimitColumns()
{
if (empty($this->limitColumns)) {
return;
}
$columns = $this->getTargetColumns();
return $columns[$this->limitColumns -1];
}
/**
@@ -1035,6 +1262,7 @@ class LaravelExcelReader
{
$spreadsheetInfo = $this->reader->listWorksheetInfo($this->file);
$index = null ;
// Loop through the info
foreach ($spreadsheetInfo as $key => $value) {
// When we hit the right worksheet
@@ -1042,6 +1270,10 @@ class LaravelExcelReader
$index = $key;
}
}
if( $index === null )
{
throw new LaravelExcelException('Active sheet not found (active sheet name: "'.$this->getActiveSheet()->getTitle().'")');
}
// return total rows
return $spreadsheetInfo[$index];
@@ -1095,6 +1327,15 @@ class LaravelExcelReader
return pathinfo($this->file, PATHINFO_FILENAME);
}
/**
* Get the row containing the header
* @return int
*/
public function getHeaderRow()
{
return $this->headerRow ?: config('excel.import.startRow', 1);
}
/**
* Check if the writer has the called method
*
@@ -1176,7 +1417,7 @@ class LaravelExcelReader
{
if ($this->format == 'CSV') {
// If no encoding was given, use the config value
$encoding = $encoding ? $encoding : Config::get('excel.import.encoding.input', 'UTF-8');
$encoding = $encoding ? $encoding : config('excel.import.encoding.input', 'UTF-8');
$this->reader->setInputEncoding($encoding);
}
@@ -1194,35 +1435,35 @@ class LaravelExcelReader
if ($this->format == 'CSV') {
// If no delimiter was given, take from config
if (!$this->delimiter) {
$this->reader->setDelimiter(Config::get('excel.csv.delimiter', ','));
$this->reader->setDelimiter(config('excel.csv.delimiter', ','));
} else {
$this->reader->setDelimiter($this->delimiter);
}
if (!$this->enclosure) {
$this->reader->setEnclosure(Config::get('excel.csv.enclosure', '"'));
$this->reader->setEnclosure(config('excel.csv.enclosure', '"'));
} else {
$this->reader->setEnclosure($this->enclosure);
}
}
// Set default calculate
$this->calculate = Config::get('excel.import.calculate', true);
$this->calculate = config('excel.import.calculate', true);
// Set default for ignoring empty cells
$this->ignoreEmpty = Config::get('excel.import.ignoreEmpty', true);
$this->ignoreEmpty = config('excel.import.ignoreEmpty', true);
// Set default date format
$this->dateFormat = Config::get('excel.import.dates.format', 'Y-m-d');
$this->dateFormat = config('excel.import.dates.format', 'Y-m-d');
// Date formatting disabled/enabled
$this->formatDates = Config::get('excel.import.dates.enabled', true);
$this->formatDates = config('excel.import.dates.enabled', true);
// Set default date columns
$this->dateColumns = Config::get('excel.import.dates.columns', []);
$this->dateColumns = config('excel.import.dates.columns', []);
// Set default include charts
$this->reader->setIncludeCharts(Config::get('excel.import.includeCharts', false));
$this->reader->setIncludeCharts(config('excel.import.includeCharts', false));
}
/**

View File

@@ -13,7 +13,8 @@ use Maatwebsite\Excel\Classes\LaravelExcelWorksheet;
* @author Maatwebsite <info@maatwebsite.nl>
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/
class CellWriter {
class CellWriter
{
/**
* Current $sheet
@@ -46,14 +47,28 @@ class CellWriter {
public function setValue($value)
{
// Only set cell value for single cells
if (!str_contains($this->cells, ':'))
{
if (!str_contains($this->cells, ':')) {
$this->sheet->setCellValue($this->cells, $value);
}
return $this;
}
/**
* Set cell url
* @param [type] $url
* @return CellWriter
*/
public function setUrl($url)
{
// Only set cell value for single cells
if (!str_contains($this->cells, ':')) {
$this->sheet->getCell($this->cells)->getHyperlink()->setUrl($url);
}
return $this;
}
/**
* Set the background
* @param string $color
@@ -94,9 +109,9 @@ class CellWriter {
*/
public function setFontFamily($family)
{
return $this->setStyle('font', array(
'name' => $family
));
return $this->setStyle('font', [
'name' => $family,
]);
}
/**
@@ -106,9 +121,9 @@ class CellWriter {
*/
public function setFontSize($size)
{
return $this->setStyle('font', array(
'size' => $size
));
return $this->setStyle('font', [
'size' => $size,
]);
}
/**
@@ -118,9 +133,9 @@ class CellWriter {
*/
public function setFontWeight($bold = true)
{
return $this->setStyle('font', array(
'bold' => ($bold == 'bold' || $bold) ? true : false
));
return $this->setStyle('font', [
'bold' => ($bold === 'bold' || $bold === true),
]);
}
/**
@@ -134,20 +149,20 @@ class CellWriter {
public function setBorder($top = 'none', $right = 'none', $bottom = 'none', $left = 'none')
{
// Set the border styles
$styles = is_array($top) ? $top : array(
'top' => array(
'style' => $top
),
'left' => array(
$styles = is_array($top) ? $top : [
'top' => [
'style' => $top,
],
'left' => [
'style' => $left,
),
'right' => array(
],
'right' => [
'style' => $right,
),
'bottom' => array(
],
'bottom' => [
'style' => $bottom,
)
);
],
];
return $this->setStyle('borders', $styles);
}
@@ -159,8 +174,8 @@ class CellWriter {
*/
public function setTextRotation($degrees)
{
$style = $this->getCellStyle()->getAlignment()->setTextRotation($degrees);
return $this;
$style = $this->getCellStyle()->getAlignment()->setTextRotation($degrees);
return $this;
}
/**
@@ -170,9 +185,9 @@ class CellWriter {
*/
public function setAlignment($alignment)
{
return $this->setStyle('alignment', array(
'horizontal' => $alignment
));
return $this->setStyle('alignment', [
'horizontal' => $alignment,
]);
}
/**
@@ -182,9 +197,9 @@ class CellWriter {
*/
public function setValignment($alignment)
{
return $this->setStyle('alignment', array(
'vertical' => $alignment
));
return $this->setStyle('alignment', [
'vertical' => $alignment,
]);
}
/**
@@ -194,8 +209,8 @@ class CellWriter {
*/
public function setTextIndent($indent)
{
$style = $this->getCellStyle()->getAlignment()->setIndent((int)$indent);
return $this;
$style = $this->getCellStyle()->getAlignment()->setIndent((int) $indent);
return $this;
}
/**
@@ -209,10 +224,10 @@ class CellWriter {
protected function setColorStyle($styleType, $color, $type = false, $colorType = 'rgb')
{
// Set the styles
$styles = is_array($color) ? $color : array(
$styles = is_array($color) ? $color : [
'type' => $type,
'color' => array($colorType => str_replace('#', '', $color))
);
'color' => [$colorType => str_replace('#', '', $color)],
];
return $this->setStyle($styleType, $styles);
}
@@ -229,9 +244,9 @@ class CellWriter {
$style = $this->getCellStyle();
// Apply style from array
$style->applyFromArray(array(
$styleType => $styles
));
$style->applyFromArray([
$styleType => $styles,
]);
return $this;
}

View File

@@ -4,7 +4,6 @@ use Closure;
use Carbon\Carbon;
use PHPExcel_IOFactory;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Response;
use Maatwebsite\Excel\Classes\FormatIdentifier;
use Maatwebsite\Excel\Classes\LaravelExcelWorksheet;
@@ -72,6 +71,22 @@ class LaravelExcelWriter {
*/
public $ext = 'xls';
/**
* Valid file extensions.
* @var array
*/
private $validExtensions = [
'xlsx', 'xlsm', 'xltx', 'xltm', //Excel 2007
'xls', 'xlt', //Excel5
'ods', 'ots', //OOCalc
'slk', //SYLK
'xml', //Excel2003XML
'gnumeric', //gnumeric
'htm', 'html', //HTML
'csv','txt' //CSV
,'pdf' //PDF
];
/**
* Path the file will be stored to
* @var string
@@ -152,7 +167,7 @@ class LaravelExcelWriter {
}
/**
* Get the title
* Get the filename
* @return string
*/
public function getFileName()
@@ -167,7 +182,7 @@ class LaravelExcelWriter {
* @param array $mergeData
* @return LaravelExcelWriter
*/
public function shareView($view, $data = array(), $mergeData = array())
public function shareView($view, $data = [], $mergeData = [])
{
// Get the parser
$this->getParser();
@@ -186,7 +201,7 @@ class LaravelExcelWriter {
*/
public function setView()
{
return call_user_func_array(array($this, 'shareView'), func_get_args());
return call_user_func_array([$this, 'shareView'], func_get_args());
}
/**
@@ -195,7 +210,7 @@ class LaravelExcelWriter {
*/
public function loadView()
{
return call_user_func_array(array($this, 'shareView'), func_get_args());
return call_user_func_array([$this, 'shareView'], func_get_args());
}
/**
@@ -220,12 +235,12 @@ class LaravelExcelWriter {
$this->sheet->setDefaultPageSetup();
// Do the callback
if ($callback instanceof Closure)
if (is_callable($callback))
call_user_func($callback, $this->sheet);
// Autosize columns when no user didn't change anything about column sizing
if (!$this->sheet->hasFixedSizeColumns())
$this->sheet->setAutosize(Config::get('excel.export.autosize', false));
$this->sheet->setAutosize(config('excel.export.autosize', false));
// Parse the sheet
$this->sheet->parsed();
@@ -252,21 +267,10 @@ class LaravelExcelWriter {
* @param array $headers
* @throws LaravelExcelException
*/
public function export($ext = 'xls', Array $headers = array())
public function export($ext = 'xls', Array $headers = [])
{
// Set the extension
$this->ext = $ext;
//Fix borders for merged cells
foreach($this->getAllSheets() as $sheet){
foreach($sheet->getMergeCells() as $cells){
$style = $sheet->getStyle(explode(':', $cells)[0]);
$sheet->duplicateStyle($style, $cells);
}
}
$this->ext = mb_strtolower($ext);
// Render the file
$this->_render();
@@ -275,12 +279,26 @@ class LaravelExcelWriter {
$this->_download($headers);
}
/**
* Check if input file extension is valid.
* @param $ext
*/
private function checkExtensionIsValid($ext)
{
// Check file extension is valid
if (!in_array($ext, $this->validExtensions))
{
throw new \InvalidArgumentException("Invalid file extension `$ext`, expected "
.implode(", ", $this->validExtensions).".");
}
}
/**
* Convert and existing file to newly requested extension
* @param $ext
* @param array $headers
*/
public function convert($ext, Array $headers = array())
public function convert($ext, Array $headers = [])
{
$this->export($ext, $headers);
}
@@ -290,7 +308,7 @@ class LaravelExcelWriter {
* @param string $ext
* @param array $headers
*/
public function download($ext = 'xls', Array $headers = array())
public function download($ext = 'xls', Array $headers = [])
{
$this->export($ext, $headers);
}
@@ -326,19 +344,19 @@ class LaravelExcelWriter {
* @param array $headers
* @throws LaravelExcelException
*/
protected function _download(Array $headers = array())
protected function _download(Array $headers = [])
{
// Set the headers
$this->_setHeaders(
$headers,
array(
[
'Content-Type' => $this->contentType,
'Content-Disposition' => 'attachment; filename="' . $this->filename . '.' . $this->ext . '"',
'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', // Date in the past
'Last-Modified' => Carbon::now()->format('D, d M Y H:i:s'),
'Cache-Control' => 'cache, must-revalidate',
'Pragma' => 'public'
)
]
);
// Check if writer isset
@@ -358,7 +376,7 @@ class LaravelExcelWriter {
* @param string $ext
* @param boolean $path
* @param boolean $returnInfo
* @return LaravelExcelWriter
* @return LaravelExcelWriter|array
*/
public function store($ext = 'xls', $path = false, $returnInfo = false)
{
@@ -366,13 +384,13 @@ class LaravelExcelWriter {
$this->_setStoragePath($path);
// Set the extension
$this->ext = $ext;
$this->ext = mb_strtolower($ext);
// Render the XLS
$this->_render();
// Set the storage path and file
$toStore = $this->storagePath . '/' . $this->filename . '.' . $this->ext;
$toStore = $this->storagePath . DIRECTORY_SEPARATOR . $this->filename . '.' . $this->ext;
// Save the file to specified location
$this->writer->save($toStore);
@@ -381,13 +399,13 @@ class LaravelExcelWriter {
if ($this->returnInfo($returnInfo))
{
// Send back information about the stored file
return array(
return [
'full' => $toStore,
'path' => $this->storagePath,
'file' => $this->filename . '.' . $this->ext,
'title' => $this->filename,
'ext' => $this->ext
);
];
}
// Return itself
@@ -401,7 +419,7 @@ class LaravelExcelWriter {
*/
public function returnInfo($returnInfo = false)
{
return $returnInfo ? $returnInfo : Config::get('excel.export.store.returnInfo', false);
return $returnInfo ? $returnInfo : config('excel.export.store.returnInfo', false);
}
/**
@@ -423,6 +441,28 @@ class LaravelExcelWriter {
*/
protected function _render()
{
// Preserve any existing active sheet index
$activeIndex = $this->getExcel()->getActiveSheetIndex();
// getAllSheets() returns $this if no sheets were added to the excel file
if ($this->getAllSheets() instanceof $this) {
throw new LaravelExcelException('[ERROR] Aborting spreadsheet render: a minimum of 1 sheet is required.');
}
//Fix borders for merged cells
foreach($this->getAllSheets() as $sheet){
foreach($sheet->getMergeCells() as $cells){
$style = $sheet->getStyle(explode(':', $cells)[0]);
$sheet->duplicateStyle($style, $cells);
}
}
// Restore active sheet index.
$this->setActiveSheetIndex($activeIndex);
// There should be enough sheets to continue rendering
if ($this->excel->getSheetCount() < 0)
throw new LaravelExcelException('[ERROR] Aborting spreadsheet render: no sheets were created.');
@@ -438,7 +478,7 @@ class LaravelExcelWriter {
}
/**
* Get the view parser
* Get the excel object
* @return PHPExcel
*/
public function getExcel()
@@ -467,6 +507,18 @@ class LaravelExcelWriter {
{
return $this->sheet;
}
/**
* Set the active sheet index
* @param integer $index
* @return LaravelExcelWriter
*/
public function setActiveSheetIndex($index)
{
$this->sheet = $this->excel->setActiveSheetIndex($index);
return $this;
}
/**
* Set attributes
@@ -482,7 +534,7 @@ class LaravelExcelWriter {
if ($this->excel->isChangeableProperty($setter))
{
// Set the properties
call_user_func_array(array($this->excel->getProperties(), $setter), $params);
call_user_func_array([$this->excel->getProperties(), $setter], $params);
}
}
@@ -508,6 +560,9 @@ class LaravelExcelWriter {
*/
protected function _setWriter()
{
// Check if input file extension is valid
$this->checkExtensionIsValid($this->ext);
// Set pdf renderer
if ($this->format == 'PDF')
{
@@ -520,10 +575,10 @@ class LaravelExcelWriter {
// Set CSV delimiter
if ($this->format == 'CSV')
{
$this->writer->setDelimiter(Config::get('excel.csv.delimiter', ','));
$this->writer->setEnclosure(Config::get('excel.csv.enclosure', '"'));
$this->writer->setLineEnding(Config::get('excel::csv.line_ending', "\r\n"));
$this->writer->setUseBOM(Config::get('excel.csv.use_bom', false));
$this->writer->setDelimiter(config('excel.csv.delimiter', ','));
$this->writer->setEnclosure(config('excel.csv.enclosure', '"'));
$this->writer->setLineEnding(config('excel.csv.line_ending', "\r\n"));
$this->writer->setUseBOM(config('excel.csv.use_bom', false));
}
// Set CSV delimiter
@@ -533,10 +588,10 @@ class LaravelExcelWriter {
}
// Calculation settings
$this->writer->setPreCalculateFormulas(Config::get('excel.export.calculate', false));
$this->writer->setPreCalculateFormulas(config('excel.export.calculate', false));
// Include Charts
$this->writer->setIncludeCharts(Config::get('excel.export.includeCharts', false));
$this->writer->setIncludeCharts(config('excel.export.includeCharts', false));
return $this->writer;
}
@@ -548,8 +603,8 @@ class LaravelExcelWriter {
protected function setPdfRenderer()
{
// Get the driver name
$driver = Config::get('excel.export.pdf.driver');
$path = Config::get('excel.export.pdf.drivers.' . $driver . '.path');
$driver = config('excel.export.pdf.driver');
$path = config('excel.export.pdf.drivers.' . $driver . '.path');
// Disable autoloading for dompdf
if(! defined("DOMPDF_ENABLE_AUTOLOAD")){
@@ -566,7 +621,7 @@ class LaravelExcelWriter {
* @param $headers
* @throws LaravelExcelException
*/
protected function _setHeaders(Array $headers = array(), Array $default)
protected function _setHeaders(Array $headers = [], Array $default)
{
if (headers_sent()) throw new LaravelExcelException('[ERROR]: Headers already sent');
@@ -587,10 +642,10 @@ class LaravelExcelWriter {
protected function _setStoragePath($path = false)
{
// Get the default path
$path = $path ? $path : Config::get('excel.export.store.path', storage_path($this->storagePath));
$path = $path ? $path : config('excel.export.store.path', storage_path($this->storagePath));
// Trim of slashes, to makes sure we won't add them double
$this->storagePath = rtrim($path, '/');
$this->storagePath = rtrim($path, DIRECTORY_SEPARATOR);
// Make sure the storage path exists
if (!$this->filesystem->exists($this->storagePath)) {
@@ -632,11 +687,21 @@ class LaravelExcelWriter {
elseif (method_exists($this->excel, $method))
{
// Call the method from the excel object with the given params
$return = call_user_func_array(array($this->excel, $method), $params);
$return = call_user_func_array([$this->excel, $method], $params);
return $return ? $return : $this;
}
throw new LaravelExcelException('[ERROR] Writer method [' . $method . '] does not exist.');
}
/**
* Valid file extensions.
* @return array
*/
public function getValidExtensions()
{
return $this->validExtensions;
}
}

View File

@@ -2,7 +2,7 @@
return array(
'cache' => array(
'cache' => [
/*
|--------------------------------------------------------------------------
@@ -29,24 +29,24 @@ return array(
| Cache settings
|--------------------------------------------------------------------------
*/
'settings' => array(
'settings' => [
'memoryCacheSize' => '32MB',
'cacheTime' => 600
),
],
/*
|--------------------------------------------------------------------------
| Memcache settings
|--------------------------------------------------------------------------
*/
'memcache' => array(
'memcache' => [
'host' => 'localhost',
'port' => 11211,
),
],
/*
|--------------------------------------------------------------------------
@@ -55,9 +55,9 @@ return array(
*/
'dir' => storage_path('cache')
),
],
'properties' => array(
'properties' => [
'creator' => 'Maatwebsite',
'lastModifiedBy' => 'Maatwebsite',
'title' => 'Spreadsheet',
@@ -67,35 +67,35 @@ return array(
'category' => 'Excel',
'manager' => 'Maatwebsite',
'company' => 'Maatwebsite',
),
],
/*
|--------------------------------------------------------------------------
| Sheets settings
|--------------------------------------------------------------------------
*/
'sheets' => array(
'sheets' => [
/*
|--------------------------------------------------------------------------
| Default page setup
|--------------------------------------------------------------------------
*/
'pageSetup' => array(
'pageSetup' => [
'orientation' => 'portrait',
'paperSize' => '9',
'scale' => '100',
'fitToPage' => false,
'fitToHeight' => true,
'fitToWidth' => true,
'columnsToRepeatAtLeft' => array('', ''),
'rowsToRepeatAtTop' => array(0, 0),
'columnsToRepeatAtLeft' => ['', ''],
'rowsToRepeatAtTop' => [0, 0],
'horizontalCentered' => false,
'verticalCentered' => false,
'printArea' => null,
'firstPageNumber' => null,
),
),
],
],
/*
|--------------------------------------------------------------------------
@@ -108,7 +108,7 @@ return array(
'creator' => 'Maatwebsite',
'csv' => array(
'csv' => [
/*
|--------------------------------------------------------------------------
| Delimiter
@@ -143,9 +143,9 @@ return array(
*/
'use_bom' => false
),
],
'export' => array(
'export' => [
/*
|--------------------------------------------------------------------------
@@ -218,7 +218,7 @@ return array(
| Default sheet settings
|--------------------------------------------------------------------------
*/
'sheets' => array(
'sheets' => [
/*
|--------------------------------------------------------------------------
@@ -254,7 +254,7 @@ return array(
|--------------------------------------------------------------------------
*/
'strictNullComparison' => false
),
],
/*
|--------------------------------------------------------------------------
@@ -262,7 +262,7 @@ return array(
|--------------------------------------------------------------------------
*/
'store' => array(
'store' => [
/*
|--------------------------------------------------------------------------
@@ -284,14 +284,14 @@ return array(
*/
'returnInfo' => false
),
],
/*
|--------------------------------------------------------------------------
| PDF Settings
|--------------------------------------------------------------------------
*/
'pdf' => array(
'pdf' => [
/*
|--------------------------------------------------------------------------
@@ -306,48 +306,48 @@ return array(
| PDF Driver settings
|--------------------------------------------------------------------------
*/
'drivers' => array(
'drivers' => [
/*
|--------------------------------------------------------------------------
| DomPDF settings
|--------------------------------------------------------------------------
*/
'DomPDF' => array(
'DomPDF' => [
'path' => base_path('vendor/dompdf/dompdf/')
),
],
/*
|--------------------------------------------------------------------------
| tcPDF settings
|--------------------------------------------------------------------------
*/
'tcPDF' => array(
'tcPDF' => [
'path' => base_path('vendor/tecnick.com/tcpdf/')
),
],
/*
|--------------------------------------------------------------------------
| mPDF settings
|--------------------------------------------------------------------------
*/
'mPDF' => array(
'mPDF' => [
'path' => base_path('vendor/mpdf/mpdf/')
),
)
)
),
],
]
]
],
'filters' => array(
'filters' => [
/*
|--------------------------------------------------------------------------
| Register read filters
|--------------------------------------------------------------------------
*/
'registered' => array(
'registered' => [
'chunk' => 'Maatwebsite\Excel\Filters\ChunkReadFilter'
),
],
/*
|--------------------------------------------------------------------------
@@ -355,10 +355,10 @@ return array(
|--------------------------------------------------------------------------
*/
'enabled' => array()
),
'enabled' => []
],
'import' => array(
'import' => [
/*
|--------------------------------------------------------------------------
@@ -367,7 +367,7 @@ return array(
|
| 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
| Options: true|false|slugged|slugged_with_count|ascii|numeric|hashed|hashed_with_lower|trans|original
|
*/
@@ -397,6 +397,19 @@ return array(
'separator' => '_',
/*
|--------------------------------------------------------------------------
| Slug whitelisting
|--------------------------------------------------------------------------
|
| Here you can whitelist certain characters in the slug.
| E.g. user.last_name will not remove . and _
| Note: only applies to 'heading' settings 'true' && 'slugged'
|
*/
'slug_whitelist' => '._',
/*
|--------------------------------------------------------------------------
| Include Charts during import
@@ -423,12 +436,12 @@ return array(
|--------------------------------------------------------------------------
*/
'encoding' => array(
'encoding' => [
'input' => 'UTF-8',
'output' => 'UTF-8'
),
],
/*
|--------------------------------------------------------------------------
@@ -474,7 +487,7 @@ return array(
|
*/
'dates' => array(
'dates' => [
/*
|--------------------------------------------------------------------------
@@ -498,15 +511,15 @@ return array(
| Date columns
|--------------------------------------------------------------------------
*/
'columns' => array()
),
'columns' => []
],
/*
|--------------------------------------------------------------------------
| Import sheets by config
|--------------------------------------------------------------------------
*/
'sheets' => array(
'sheets' => [
/*
|--------------------------------------------------------------------------
@@ -517,16 +530,16 @@ return array(
|
*/
'test' => array(
'test' => [
'firstname' => 'A2'
)
]
)
),
]
],
'views' => array(
'views' => [
/*
|--------------------------------------------------------------------------
@@ -537,155 +550,155 @@ return array(
|
*/
'styles' => array(
'styles' => [
/*
|--------------------------------------------------------------------------
| Table headings
|--------------------------------------------------------------------------
*/
'th' => array(
'font' => array(
'th' => [
'font' => [
'bold' => true,
'size' => 12,
)
),
]
],
/*
|--------------------------------------------------------------------------
| Strong tags
|--------------------------------------------------------------------------
*/
'strong' => array(
'font' => array(
'strong' => [
'font' => [
'bold' => true,
'size' => 12,
)
),
]
],
/*
|--------------------------------------------------------------------------
| Bold tags
|--------------------------------------------------------------------------
*/
'b' => array(
'font' => array(
'b' => [
'font' => [
'bold' => true,
'size' => 12,
)
),
]
],
/*
|--------------------------------------------------------------------------
| Italic tags
|--------------------------------------------------------------------------
*/
'i' => array(
'font' => array(
'i' => [
'font' => [
'italic' => true,
'size' => 12,
)
),
]
],
/*
|--------------------------------------------------------------------------
| Heading 1
|--------------------------------------------------------------------------
*/
'h1' => array(
'font' => array(
'h1' => [
'font' => [
'bold' => true,
'size' => 24,
)
),
]
],
/*
|--------------------------------------------------------------------------
| Heading 2
|--------------------------------------------------------------------------
*/
'h2' => array(
'font' => array(
'h2' => [
'font' => [
'bold' => true,
'size' => 18,
)
),
]
],
/*
|--------------------------------------------------------------------------
| Heading 2
| Heading 3
|--------------------------------------------------------------------------
*/
'h3' => array(
'font' => array(
'h3' => [
'font' => [
'bold' => true,
'size' => 13.5,
)
),
]
],
/*
|--------------------------------------------------------------------------
| Heading 4
|--------------------------------------------------------------------------
*/
'h4' => array(
'font' => array(
'h4' => [
'font' => [
'bold' => true,
'size' => 12,
)
),
]
],
/*
|--------------------------------------------------------------------------
| Heading 5
|--------------------------------------------------------------------------
*/
'h5' => array(
'font' => array(
'h5' => [
'font' => [
'bold' => true,
'size' => 10,
)
),
]
],
/*
|--------------------------------------------------------------------------
| Heading 6
|--------------------------------------------------------------------------
*/
'h6' => array(
'font' => array(
'h6' => [
'font' => [
'bold' => true,
'size' => 7.5,
)
),
]
],
/*
|--------------------------------------------------------------------------
| Hyperlinks
|--------------------------------------------------------------------------
*/
'a' => array(
'font' => array(
'a' => [
'font' => [
'underline' => true,
'color' => array('argb' => 'FF0000FF'),
)
),
'color' => ['argb' => 'FF0000FF'],
]
],
/*
|--------------------------------------------------------------------------
| Horizontal rules
|--------------------------------------------------------------------------
*/
'hr' => array(
'borders' => array(
'bottom' => array(
'hr' => [
'borders' => [
'bottom' => [
'style' => 'thin',
'color' => array('FF000000')
),
)
)
)
'color' => ['FF000000']
],
]
]
]
)
]
);