update 1.0.8.0
Commits for version update
This commit is contained in:
22
vendor/maatwebsite/excel/.github/CONTRIBUTING.md
vendored
Normal file
22
vendor/maatwebsite/excel/.github/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# Contribution Guide
|
||||
|
||||
### Bug fixes
|
||||
|
||||
**ALL** bug fixes should be made to appropriate branch (e.g. `1.1` for 1.1.* bug fixes). Bug fixes should never be sent to the `master` branch.
|
||||
|
||||
### Pull Requests
|
||||
|
||||
Every pull request should pass the unit tests. If you include new functionality, make sure you include a test. Pull requests will be evaluated and possibly added to the next stable release.
|
||||
|
||||
### Feature Requests
|
||||
|
||||
If you have an idea for a new feature you would like to see added to Laravel Excel, you may create an issue on GitHub with `[PROPOSAL]` in the title. The feature request will then be reviewed by @Maatwebsite.
|
||||
|
||||
### Coding Guidelines
|
||||
|
||||
Laravel, and therefore Maatwebsite's Laravel Excel follows the [PSR-0](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md) and [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) coding standards. In addition to these standards, below is a list of other coding standards that should be followed:
|
||||
|
||||
- Namespace declarations should be on the same line as `<?php`.
|
||||
- Class opening `{` should be on the same line as the class name.
|
||||
- Function and control structure opening `{` should be on a separate line.
|
||||
- Interface and Trait names are suffixed with `Interface` (`FooInterface`) and `Trait` (`FooTrait`) respectively.
|
13
vendor/maatwebsite/excel/.github/ISSUE_TEMPLATE.md
vendored
Normal file
13
vendor/maatwebsite/excel/.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Please prefix your issue with one of the following: [BUG] [PROPOSAL] [QUESTION].
|
||||
|
||||
### Package version, Laravel version
|
||||
|
||||
### Expected behaviour
|
||||
|
||||
### Actual behaviour
|
||||
|
||||
#### Exception stack trace
|
||||
|
||||
#### Screenshot of Excel file
|
||||
|
||||
### Steps to reproduce the behaviour
|
4
vendor/maatwebsite/excel/.gitignore
vendored
Normal file
4
vendor/maatwebsite/excel/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/vendor
|
||||
composer.phar
|
||||
composer.lock
|
||||
.DS_Store
|
17
vendor/maatwebsite/excel/.travis.yml
vendored
Normal file
17
vendor/maatwebsite/excel/.travis.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7
|
||||
|
||||
before_script:
|
||||
- travis_retry composer self-update
|
||||
- travis_retry composer install --prefer-source --no-interaction
|
||||
|
||||
script: phpunit
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
fast_finish: true
|
345
vendor/maatwebsite/excel/LICENSE
vendored
Normal file
345
vendor/maatwebsite/excel/LICENSE
vendored
Normal file
@@ -0,0 +1,345 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
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".
|
||||
|
||||
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 "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
|
111
vendor/maatwebsite/excel/README.md
vendored
Normal file
111
vendor/maatwebsite/excel/README.md
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
## Laravel Excel v2.1.* for Laravel 5
|
||||
|
||||
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="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.
|
||||
|
||||
- Import into Laravel **Collections**
|
||||
- Export **Blade views** to Excel and CSV with optional CSS styling
|
||||
- **Batch** imports
|
||||
- A lot of optional **config settings**
|
||||
- Easy **cell caching**
|
||||
- Chunked and queued importer
|
||||
- ExcelFile method injections
|
||||
- Editing existing Excel files
|
||||
- **Advanced import** by config files
|
||||
- and many more...
|
||||
|
||||
---
|
||||
|
||||
```php
|
||||
Excel::create('Laravel Excel', function($excel) {
|
||||
|
||||
$excel->sheet('Excel sheet', function($sheet) {
|
||||
|
||||
$sheet->setOrientation('landscape');
|
||||
|
||||
});
|
||||
|
||||
})->export('xls');
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
[](https://travis-ci.org/Maatwebsite/Laravel-Excel)
|
||||
[](https://packagist.org/packages/maatwebsite/excel) [](https://packagist.org/packages/maatwebsite/excel) [](https://packagist.org/packages/maatwebsite/excel)
|
||||
[](https://packagist.org/packages/maatwebsite/excel)
|
||||
[](https://packagist.org/packages/maatwebsite/excel)
|
||||
|
||||
[](http://pledgie.com/campaigns/30385)
|
||||
|
||||
#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"
|
||||
```
|
||||
|
||||
For Laravel 5.2 use you have to install the [laravelcollective/bus](https://laravelcollective.com/docs/5.2/bus#installation) package.
|
||||
Add this to the `composer.json` and update composer:
|
||||
|
||||
```php
|
||||
"laravelcollective/bus": "^5.2"
|
||||
```
|
||||
|
||||
Then add the following lines to the `config/app.php`:
|
||||
|
||||
```php
|
||||
'providers' => [
|
||||
// ...
|
||||
Collective\Bus\BusServiceProvider::class,
|
||||
// ...
|
||||
],
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```php
|
||||
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
|
||||
```
|
||||
|
||||
The class is bound to the ioC as `excel`
|
||||
|
||||
```php
|
||||
$excel = App::make('excel');
|
||||
```
|
||||
|
||||
To publish the config settings in Laravel 5 use:
|
||||
|
||||
```php
|
||||
php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider"
|
||||
```
|
||||
|
||||
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)
|
||||
|
||||
# Support
|
||||
|
||||
Support only through Github. Please don't mail us about issues, make a Github issue instead.
|
||||
|
||||
# Contributing
|
||||
|
||||
**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)
|
||||
|
||||
# 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!
|
55
vendor/maatwebsite/excel/composer.json
vendored
Normal file
55
vendor/maatwebsite/excel/composer.json
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "maatwebsite/excel",
|
||||
"description": "An eloquent way of importing and exporting Excel and CSV in Laravel 4 with the power of PHPExcel",
|
||||
"license": "LGPL",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"phpexcel",
|
||||
"excel",
|
||||
"csv",
|
||||
"export",
|
||||
"import",
|
||||
"batch"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Maatwebsite.nl",
|
||||
"email": "patrick@maatwebsite.nl"
|
||||
}
|
||||
],
|
||||
"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.*",
|
||||
"nesbot/carbon": "~1.0",
|
||||
"tijsverkoyen/css-to-inline-styles": "~1.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpseclib/phpseclib": "~1.0",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"mockery/mockery": "~0.9",
|
||||
"orchestra/testbench": "3.1.*"
|
||||
},
|
||||
"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.*"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/Maatwebsite/Excel"
|
||||
],
|
||||
"psr-0": {
|
||||
"Maatwebsite\\Excel\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [
|
||||
"tests/TestCase.php"
|
||||
]
|
||||
}
|
||||
}
|
3
vendor/maatwebsite/excel/docs/blade.md
vendored
Normal file
3
vendor/maatwebsite/excel/docs/blade.md
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
@include:Loading a view|load-view
|
||||
@include:Passing variables|vars
|
||||
@include:Styling sheets|styling
|
45
vendor/maatwebsite/excel/docs/blade/load-view.md
vendored
Normal file
45
vendor/maatwebsite/excel/docs/blade/load-view.md
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
# @Blade to Excel
|
||||
|
||||
We can utilise the magic of Laravel's Blade engine to power our Excel export. Sharing a view, loading a view per sheet, creating a html table inside a view, basic CSS styling, ...
|
||||
|
||||
# Loading a view for a single sheet
|
||||
|
||||
We can load a view for every sheet we create with `->loadView()`.
|
||||
|
||||
Excel::create('New file', function($excel) {
|
||||
|
||||
$excel->sheet('New sheet', function($sheet) {
|
||||
|
||||
$sheet->loadView('folder.view');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
# Using different views for different sheets
|
||||
|
||||
Excel::create('New file', function($excel) {
|
||||
|
||||
$excel->sheet('First sheet', function($sheet) {
|
||||
|
||||
$sheet->loadView('view_first');
|
||||
});
|
||||
|
||||
$excel->sheet('Second sheet', function($sheet) {
|
||||
|
||||
$sheet->loadView('view_second');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
# Sharing a view for all sheets
|
||||
|
||||
We can share a view for all sheets with `shareView()`.
|
||||
|
||||
Excel::shareView('folder.view')->create();
|
||||
|
||||
# Unsetting a view for a sheet
|
||||
|
||||
When we are using a shared view, but we don't want to use a view for the current sheet, we can use `->unsetView()`.
|
||||
|
||||
$sheet->unsetView();
|
133
vendor/maatwebsite/excel/docs/blade/styling.md
vendored
Normal file
133
vendor/maatwebsite/excel/docs/blade/styling.md
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
# Styling sheets
|
||||
|
||||
### General styling
|
||||
|
||||
If you want to change the general styling of your sheet (not cell or range specific), you can use the `->setStyle()` method or any of the other setters which can be found inside the export documentation.
|
||||
|
||||
// Font family
|
||||
$sheet->setFontFamily('Comic Sans MS');
|
||||
|
||||
// Set font with ->setStyle()`
|
||||
$sheet->setStyle(array(
|
||||
'font' => array(
|
||||
'name' => 'Calibri',
|
||||
'size' => 12,
|
||||
'bold' => true
|
||||
)
|
||||
));
|
||||
|
||||
### Styling with PHPExcel methods
|
||||
|
||||
It's possible to style the sheets and specific cells with help of PHPExcel methods. This package includes a lot of shortcuts (see export documentation), but also always the use of the native methods.
|
||||
|
||||
// Set background color for a specific cell
|
||||
$sheet->getStyle('A1')->applyFromArray(array(
|
||||
'fill' => array(
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'color' => array('rgb' => 'FF0000')
|
||||
)
|
||||
));
|
||||
|
||||
### Using HTML tags
|
||||
|
||||
Most of the HTML tags are supported.
|
||||
|
||||
<html>
|
||||
|
||||
<!-- Headings -->
|
||||
<td><h1>Big title</h1></td>
|
||||
|
||||
<!-- Bold -->
|
||||
<td><b>Bold cell</b></td>
|
||||
<td><strong>Bold cell</strong></td>
|
||||
|
||||
<!-- Italic -->
|
||||
<td><i>Italic cell</i></td>
|
||||
|
||||
<!-- Images -->
|
||||
<td><img src="img.jpg" /></td>
|
||||
|
||||
</html>
|
||||
|
||||
> Inside the `view.php` config you can change how these tags will be interpreted by Excel by default.
|
||||
|
||||
### Using HTML attributes
|
||||
|
||||
Some of the basic styling can be done with HTML attributes.
|
||||
|
||||
<html>
|
||||
|
||||
<!-- Horizontal alignment -->
|
||||
<td align="right">Big title</td>
|
||||
|
||||
<!-- Vertical alignment -->
|
||||
<td valign="middle">Bold cell</td>
|
||||
|
||||
<!-- Rowspan -->
|
||||
<td rowspan="3">Bold cell</td>
|
||||
|
||||
<!-- Colspan -->
|
||||
<td colspan="6">Italic cell</td>
|
||||
|
||||
<!-- Width -->
|
||||
<td width="100">Cell with width of 100</td>
|
||||
|
||||
<!-- Height -->
|
||||
<td height="100">Cell with height of 100</td>
|
||||
|
||||
</html>
|
||||
|
||||
### Styling through inline-styles
|
||||
|
||||
It's possible to use inline styles inside your view files. Most of the general styles are supported.
|
||||
|
||||
<html>
|
||||
|
||||
<!-- Cell with black background -->
|
||||
<td style="background-color: #000000;">Cell</td>
|
||||
|
||||
</html>
|
||||
|
||||
> Inside the reference guide you can find a list of supported styles.
|
||||
|
||||
### Styling through external CSS file
|
||||
|
||||
Styling can be done through an external CSS file.
|
||||
|
||||
External css file:
|
||||
|
||||
#cell {
|
||||
background-color: #000000;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.cell {
|
||||
background-color: #000000;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
tr td {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
tr > td {
|
||||
border-bottom: 1px solid #000000;
|
||||
}
|
||||
|
||||
Table:
|
||||
|
||||
<html>
|
||||
|
||||
{{ HTML::style('css/table.css') }}
|
||||
|
||||
<!-- Cell styled with class -->
|
||||
<td class="cell">Cell</td>
|
||||
|
||||
<!-- Cell styled with ID -->
|
||||
<td id="cell">Cell</td>
|
||||
|
||||
</html>
|
||||
|
||||
> Inside the reference guide you can find a list of supported styles.
|
||||
|
||||
> It's advised to include `<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />` into the view to fix problems with UTF-8 encoding.
|
19
vendor/maatwebsite/excel/docs/blade/vars.md
vendored
Normal file
19
vendor/maatwebsite/excel/docs/blade/vars.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Passing variables to the view
|
||||
|
||||
### As parameter
|
||||
|
||||
We can pass variables to the view by using the second parameter inside the `loadView()` method.
|
||||
|
||||
$sheet->loadView('view', array('key' => 'value'));
|
||||
|
||||
### With with()
|
||||
|
||||
Alternatively you can use the `with()` method which works the same as with Laravel views.
|
||||
|
||||
// Using normal with()
|
||||
$sheet->loadView('view')
|
||||
->with('key', 'value');
|
||||
|
||||
// using dynamic with()
|
||||
$sheet->loadView('view')
|
||||
->withKey('value');
|
14
vendor/maatwebsite/excel/docs/borders.md
vendored
Normal file
14
vendor/maatwebsite/excel/docs/borders.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
PHPExcel_Style_Border::BORDER_NONE = 'none'
|
||||
PHPExcel_Style_Border::BORDER_DASHDOT = 'dashDot'
|
||||
PHPExcel_Style_Border::BORDER_DASHDOTDOT = 'dashDotDot'
|
||||
PHPExcel_Style_Border::BORDER_DASHED = 'dashed'
|
||||
PHPExcel_Style_Border::BORDER_DOTTED = 'dotted'
|
||||
PHPExcel_Style_Border::BORDER_DOUBLE = 'double'
|
||||
PHPExcel_Style_Border::BORDER_HAIR = 'hair'
|
||||
PHPExcel_Style_Border::BORDER_MEDIUM = 'medium'
|
||||
PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT = 'mediumDashDot'
|
||||
PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT = 'mediumDashDotDot'
|
||||
PHPExcel_Style_Border::BORDER_MEDIUMDASHED = 'mediumDashed'
|
||||
PHPExcel_Style_Border::BORDER_SLANTDASHDOT = 'slantDashDot'
|
||||
PHPExcel_Style_Border::BORDER_THICK = 'thick'
|
||||
PHPExcel_Style_Border::BORDER_THIN = 'thin'
|
2
vendor/maatwebsite/excel/docs/changelog.md
vendored
Normal file
2
vendor/maatwebsite/excel/docs/changelog.md
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
@include:Version 1|version-1
|
||||
@include:Version 2|version-2
|
209
vendor/maatwebsite/excel/docs/changelog/version-1.md
vendored
Normal file
209
vendor/maatwebsite/excel/docs/changelog/version-1.md
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
# Version 1
|
||||
|
||||
### 1.3.5
|
||||
- PHPExcel 1.8.1 compatibility
|
||||
- Clean-up ServiceProvider
|
||||
- Fix short array syntax for PHP5.3
|
||||
|
||||
### 1.3.4
|
||||
- Fix usage of sheet callback when modifying an existing file
|
||||
- Modifying existing files improvements (support style overriding)
|
||||
- Add text-indent support to HtmlReader
|
||||
- Add simple sheet password protection
|
||||
- Add support for exporting multiple pdf pages
|
||||
- Add inline cell formatting to blade
|
||||
|
||||
### 1.3.3
|
||||
- Fix issue with different start row in chunk filter
|
||||
|
||||
### 1.3.2
|
||||
- Custom value binders
|
||||
- Html reader update
|
||||
|
||||
### 1.3.1
|
||||
- Fix short array syntax
|
||||
|
||||
### 1.3.0
|
||||
- Additional headers with export()
|
||||
- Float, integer, string, timestamps problems
|
||||
- Cell content ending by zeros
|
||||
- Images in html
|
||||
- Font family bug
|
||||
- Setting row number of row with headings
|
||||
|
||||
### 1.2.3
|
||||
- PDF writer
|
||||
- Include charts config
|
||||
- Chunk filter with selected sheet
|
||||
- Compatibility fix with new PHPExcel release
|
||||
- setDateColumns fix
|
||||
- Optional dependencies to require-dev
|
||||
- Several bugfixes
|
||||
|
||||
### 1.2.2
|
||||
- Chunk filter fixes
|
||||
- Isset() CellCollection fixes
|
||||
- PHP 5.3 support
|
||||
- Missing border styles
|
||||
- Add CSV settings (delimiter, enclosure, lineEnding) to ExcelFile objects
|
||||
|
||||
### 1.2.1
|
||||
- Fix with() method parameters
|
||||
|
||||
### 1.2.0
|
||||
- Filters
|
||||
- Chunk filter (with chunked importer)
|
||||
- ExcelFile (method) injections
|
||||
- NewExcelFile (method) injections
|
||||
- Edit existing worksheets
|
||||
- Converting existing worksheet
|
||||
- Laravel 4.* + 5.0 support
|
||||
|
||||
### 1.1.9
|
||||
- PHP 5.3 fixes
|
||||
|
||||
### 1.1.8
|
||||
- PHP 5.3 support
|
||||
- fromArray bugfix
|
||||
|
||||
### 1.1.7
|
||||
- Fix heading generation for export with `->fromArray()`
|
||||
- Bugfix for non-Unix kernels
|
||||
- Enhanced CSS parser (thanks to `tijsverkoyen/CssToInlineStyles`)
|
||||
- Support for nested CSS styles
|
||||
- Support for multiple css attributes per class
|
||||
- Support for internal and external CSS files
|
||||
- Support for inline style blocks (`<style>`)
|
||||
|
||||
### 1.1.6
|
||||
|
||||
- Provides.json fix
|
||||
- DocBlock fixes
|
||||
- Define Illuminate dependencies inside composer.json
|
||||
- Better HTML rowspan handling views
|
||||
- use new CellCollection() instead of ::make, to support upcoming Laravel version
|
||||
- Workaround for long integers
|
||||
- Add support to `wrap-text` in views
|
||||
- Fix empty dates parsing
|
||||
- Support local stylesheets in view parsing
|
||||
- Push tr classes to td-children in views
|
||||
- Support for dynamically appending rows to an empty (new) sheet
|
||||
- Fix separator typo in config
|
||||
|
||||
### 1.1.5
|
||||
|
||||
- Select sheets by index with `Excel::selectSheetsByIndex(0,1)->load(...)`
|
||||
- Separator typo fix
|
||||
- Added `->setFileName()` method
|
||||
- Use `->setTitle()` only for workbook title not for setting the filename anymore
|
||||
- Made `setAutoSize()` chainable for other sheet methods
|
||||
- Export config setting to disable pre calculation of formulas during export
|
||||
- Export config setting to set the autosizing method (approx|exact)
|
||||
- Auto sizing export from view fix
|
||||
|
||||
### 1.1.4
|
||||
|
||||
- Fix for importing 0 as null
|
||||
- New unit tests
|
||||
|
||||
### 1.1.3
|
||||
|
||||
- Cell writer `->setBorder()` fix
|
||||
|
||||
### 1.1.2
|
||||
|
||||
- Fix for multiple imports on one pageload
|
||||
- Multiple new import heading conversions (`Config: excel::import.heading: true|false|slugged|ascii|numeric|hashed|trans|original`)
|
||||
|
||||
### 1.1.1
|
||||
|
||||
- Retrieve workbook and sheet title during import (`->getTitle()`)
|
||||
|
||||
### 1.1.0
|
||||
|
||||
- `Limit()`, `skip()` and `take()` support for fetching results
|
||||
- Set default page margins
|
||||
- Export Eloquent models directly (`fromModel()`)
|
||||
- Auto generate the first row (table heading) from the array keys
|
||||
- Manipulate cells and cell ranges inside a closure
|
||||
- Set cell backgrounds/fonts/values, ...
|
||||
- Create/append/prepend new row/rows
|
||||
- Manipulate row cells (background, fonts, ...)
|
||||
- Config value default alignment on merge cells
|
||||
- DocBlock updates to support better use of IDE autocomplete features
|
||||
- Parse width and height inside views
|
||||
- Parse images in views
|
||||
- Optional to ASCII conversion of imported header columns (array indices)
|
||||
- Config values for default null comparision and start cells for exports
|
||||
- Changed default CSV enclosure to `"`
|
||||
- Support for Laravel package installer
|
||||
|
||||
### 1.0.9
|
||||
|
||||
- Blade to Excel export fix for PHP5.3
|
||||
|
||||
### 1.0.8
|
||||
|
||||
- File format identifier enhancements
|
||||
|
||||
### 1.0.7
|
||||
|
||||
- Set workbook properties fix
|
||||
- Extra units tests
|
||||
|
||||
### 1.0.6
|
||||
|
||||
- BatchReader fix
|
||||
|
||||
### 1.0.5
|
||||
|
||||
- Date parsing fix
|
||||
|
||||
### 1.0.4
|
||||
|
||||
- Fix calling $this in anonymous function to set locale and cache
|
||||
|
||||
### 1.0.3
|
||||
|
||||
- Table headings to attribute names undefined offset fix
|
||||
- Composer.json enhancements
|
||||
- Documentation fixes
|
||||
|
||||
### 1.0.2
|
||||
|
||||
- Cell Collection fixes
|
||||
- Default autosizing bugfixes
|
||||
- ->load() accepts input encoding parameter
|
||||
- Documentation fixes
|
||||
|
||||
### 1.0.1
|
||||
|
||||
- Column width and row height bugfix
|
||||
- Typo fixes
|
||||
|
||||
### 1.0.0
|
||||
|
||||
- New documentation
|
||||
- More logical file structure (dividing into files, separating the different functionality (import / export)
|
||||
- More optional config settings
|
||||
- CSV Delimiter fixes
|
||||
- CSV Encoding
|
||||
- Import into collections (to support utilisation of ->first(), etc.)
|
||||
- Better column selecting and result limiting
|
||||
- Batch upload
|
||||
- Import dates as Carbon objects by default
|
||||
- Advanced file import through config coordinates
|
||||
- Select sheets to import
|
||||
- Create closure (Excel::create('file', function($excel) { } ))
|
||||
- More logical syntax for creating new files, syntaxes of creating by array and creating with view should be as identical as possible
|
||||
- Rewrite of sheet building for views
|
||||
- Using closures to build sheets for normal sheet creation
|
||||
- Better support for calling native PHPExcel methods
|
||||
- Better use of setters
|
||||
- Config setting to set default store behavior
|
||||
- Column/row width
|
||||
- Share views over all sheets + easy views switching per sheet
|
||||
- External stylesheet with classes/ids parsing for views
|
||||
- Colspan fix
|
||||
- Th default styling
|
||||
- Caching / Cell caching
|
23
vendor/maatwebsite/excel/docs/changelog/version-2.md
vendored
Normal file
23
vendor/maatwebsite/excel/docs/changelog/version-2.md
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# Version 2
|
||||
|
||||
### 2.0.4
|
||||
- PHPExcel 1.8.1 compatibility
|
||||
- Clean-up ServiceProvider
|
||||
|
||||
### 2.0.3
|
||||
- Fix usage of sheet callback when modifying an existing file
|
||||
- Modifying existing files improvements (support style overriding)
|
||||
- Add text-indent support to HtmlReader
|
||||
- Add simple sheet password protection
|
||||
- Add support for exporting multiple pdf pages
|
||||
- Add inline cell formatting to blade
|
||||
|
||||
### 2.0.2
|
||||
- Fix issue with different start row in chunk filter
|
||||
|
||||
### 2.0.1
|
||||
- Custom value binders
|
||||
- Html reader update
|
||||
|
||||
### 2.0.0
|
||||
- Laravel 5 release
|
16
vendor/maatwebsite/excel/docs/export.md
vendored
Normal file
16
vendor/maatwebsite/excel/docs/export.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
@include:Creating a new file|simple
|
||||
@include:Exporting|export
|
||||
@include:NewExcelFile injections|injection
|
||||
@include:Store to server|store
|
||||
@include:Creating Sheets|sheets
|
||||
@include:Creatings Sheets From array|array
|
||||
@include:Row manipulation|rows
|
||||
@include:Cell manipulation|cells
|
||||
@include:Sheet styling|sheet-styling
|
||||
@include:Freeze rows|freeze
|
||||
@include:Auto filter|autofilter
|
||||
@include:Cell sizing|sizing
|
||||
@include:Auto size|autosize
|
||||
@include:Column merging|merge
|
||||
@include:Column formatting|format
|
||||
@include:PHPExcel methods|call
|
62
vendor/maatwebsite/excel/docs/export/array.md
vendored
Normal file
62
vendor/maatwebsite/excel/docs/export/array.md
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
# Creating a sheet from an array
|
||||
|
||||
## Array
|
||||
|
||||
To create a new file from an array use `->fromArray($source, $nullValue, $startCell, $strictNullComparison, $headingGeneration)` inside the sheet closure.
|
||||
|
||||
Excel::create('Filename', function($excel) {
|
||||
|
||||
$excel->sheet('Sheetname', function($sheet) {
|
||||
|
||||
$sheet->fromArray(array(
|
||||
array('data1', 'data2'),
|
||||
array('data3', 'data4')
|
||||
));
|
||||
|
||||
});
|
||||
|
||||
})->export('xls');
|
||||
|
||||
Alternatively you can use `->with()`.
|
||||
|
||||
$sheet->with(array(
|
||||
array('data1', 'data2'),
|
||||
array('data3', 'data4')
|
||||
));
|
||||
|
||||
If you want to pass variables inside the closure, use `use($data)`
|
||||
|
||||
$data = array(
|
||||
array('data1', 'data2'),
|
||||
array('data3', 'data4')
|
||||
);
|
||||
|
||||
Excel::create('Filename', function($excel) use($data) {
|
||||
|
||||
$excel->sheet('Sheetname', function($sheet) use($data) {
|
||||
|
||||
$sheet->fromArray($data);
|
||||
|
||||
});
|
||||
|
||||
})->export('xls');
|
||||
|
||||
### Null comparision
|
||||
|
||||
By default 0 is shown as an empty cell. If you want to change this behaviour, you can pass true as 4th parameter:
|
||||
|
||||
// Will show 0 as 0
|
||||
$sheet->fromArray($data, null, 'A1', true);
|
||||
|
||||
>> To change the default behaviour, you can use `excel::export.sheets.strictNullComparison` config setting.
|
||||
|
||||
## Eloquent model
|
||||
|
||||
It's also possible to pass an Eloquent model and export it by using `->fromModel($model)`. The method accepts the same parameters as fromArray
|
||||
|
||||
## Auto heading generation
|
||||
|
||||
By default the export will use the keys of your array (or model attribute names) as first row (header column). To change this behaviour you can edit the default config setting (`excel::export.generate_heading_by_indices`) or pass `false` as 5th parameter:
|
||||
|
||||
// Won't auto generate heading columns
|
||||
$sheet->fromArray($data, null, 'A1', false, false);
|
9
vendor/maatwebsite/excel/docs/export/autofilter.md
vendored
Normal file
9
vendor/maatwebsite/excel/docs/export/autofilter.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Auto filter
|
||||
|
||||
To enable the auto filter use `->setAutoFilter($range = false)`.
|
||||
|
||||
// Auto filter for entire sheet
|
||||
$sheet->setAutoFilter();
|
||||
|
||||
// Set auto filter for a range
|
||||
$sheet->setAutoFilter('A1:E10');
|
16
vendor/maatwebsite/excel/docs/export/autosize.md
vendored
Normal file
16
vendor/maatwebsite/excel/docs/export/autosize.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# Auto size
|
||||
|
||||
By default the exported file be automatically auto sized. To change this behaviour you can either change the config or use the setters:
|
||||
|
||||
// Set auto size for sheet
|
||||
$sheet->setAutoSize(true);
|
||||
|
||||
// Disable auto size for sheet
|
||||
$sheet->setAutoSize(false);
|
||||
|
||||
// Disable auto size for columns
|
||||
$sheet->setAutoSize(array(
|
||||
'A', 'C'
|
||||
));
|
||||
|
||||
> The default config setting can be found in: `export.php`.
|
19
vendor/maatwebsite/excel/docs/export/call.md
vendored
Normal file
19
vendor/maatwebsite/excel/docs/export/call.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Calling PHPExcel's native methods
|
||||
|
||||
It's possible to call all native PHPExcel methods on the `$excel` and `$sheet` objects.
|
||||
|
||||
### Calling Workbook methods
|
||||
|
||||
Example:
|
||||
|
||||
// Get default style for this workbook
|
||||
$excel->getDefaultStyle();
|
||||
|
||||
### Calling worksheet methods
|
||||
|
||||
Example:
|
||||
|
||||
// Protect cells
|
||||
$sheet->protectCells('A1', $password);
|
||||
|
||||
> Head over to PHPOffice to learn more about the native methods.
|
63
vendor/maatwebsite/excel/docs/export/cells.md
vendored
Normal file
63
vendor/maatwebsite/excel/docs/export/cells.md
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
# Cell manipulation
|
||||
|
||||
$sheet->cell('A1', function($cell) {
|
||||
|
||||
// manipulate the cell
|
||||
|
||||
});
|
||||
|
||||
$sheet->cells('A1:A5', function($cells) {
|
||||
|
||||
// manipulate the range of cells
|
||||
|
||||
});
|
||||
|
||||
### Set background
|
||||
|
||||
To change the background of a range of cells we can use `->setBackground($color, $type, $colorType)`
|
||||
|
||||
// Set black background
|
||||
$cells->setBackground('#000000');
|
||||
|
||||
### Change fonts
|
||||
|
||||
// Set with font color
|
||||
$cells->setFontColor('#ffffff');
|
||||
|
||||
// Set font family
|
||||
$cells->setFontFamily('Calibri');
|
||||
|
||||
// Set font size
|
||||
$cells->setFontSize(16);
|
||||
|
||||
// Set font weight to bold
|
||||
$cells->setFontWeight('bold');
|
||||
|
||||
// Set font
|
||||
$cells->setFont(array(
|
||||
'family' => 'Calibri',
|
||||
'size' => '16',
|
||||
'bold' => true
|
||||
));
|
||||
|
||||
### Set borders
|
||||
|
||||
// Set all borders (top, right, bottom, left)
|
||||
$cells->setBorder('solid', 'none', 'none', 'solid');
|
||||
|
||||
// Set borders with array
|
||||
$cells->setBorder(array(
|
||||
'top' => array(
|
||||
'style' => 'solid'
|
||||
),
|
||||
));
|
||||
|
||||
### Set horizontal alignment
|
||||
|
||||
// Set alignment to center
|
||||
$cells->setAlignment('center');
|
||||
|
||||
### Set vertical alignment
|
||||
|
||||
// Set vertical alignment to middle
|
||||
$cells->setValignment('center');
|
34
vendor/maatwebsite/excel/docs/export/export.md
vendored
Normal file
34
vendor/maatwebsite/excel/docs/export/export.md
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
# Exporting
|
||||
|
||||
To download the created file, use `->export($ext)` or `->download($ext)`.
|
||||
|
||||
#### Export to Excel5 (xls)
|
||||
|
||||
Excel::create('Filename', function($excel) {
|
||||
|
||||
})->export('xls');
|
||||
|
||||
// or
|
||||
->download('xls');
|
||||
|
||||
#### Export to Excel2007 (xlsx)
|
||||
|
||||
->export('xlsx');
|
||||
|
||||
// or
|
||||
->download('xlsx');
|
||||
|
||||
#### Export to CSV
|
||||
|
||||
->export('csv');
|
||||
|
||||
// or
|
||||
->download('csv');
|
||||
|
||||
> You can set the default enclosure and delimiter inside the config
|
||||
|
||||
#### Export to PDF
|
||||
|
||||
To export files to pdf, you will have to include `"dompdf/dompdf": "~0.6.1"`, `"mpdf/mpdf": "~5.7.3"` or `"tecnick.com/tcpdf": "~6.0.0"` in your `composer.json` and change the `export.pdf.driver` config setting accordingly.
|
||||
|
||||
->export('pdf');
|
23
vendor/maatwebsite/excel/docs/export/format.md
vendored
Normal file
23
vendor/maatwebsite/excel/docs/export/format.md
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# Column formatting
|
||||
|
||||
To tell Excel how it should interpret certain columns, you can use `->setColumnFormat($array)`.
|
||||
|
||||
// Format column as percentage
|
||||
$sheet->setColumnFormat(array(
|
||||
'C' => '0%'
|
||||
));
|
||||
|
||||
// Format a range with e.g. leading zeros
|
||||
$sheet->setColumnFormat(array(
|
||||
'A2:K2' => '0000'
|
||||
));
|
||||
|
||||
// Set multiple column formats
|
||||
$sheet->setColumnFormat(array(
|
||||
'B' => '0',
|
||||
'D' => '0.00',
|
||||
'F' => '@',
|
||||
'F' => 'yyyy-mm-dd',
|
||||
));
|
||||
|
||||
> Go to the reference guide to see a list of available formats.
|
15
vendor/maatwebsite/excel/docs/export/freeze.md
vendored
Normal file
15
vendor/maatwebsite/excel/docs/export/freeze.md
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# Freeze rows
|
||||
|
||||
If you want to freeze a cell, row or column, use:
|
||||
|
||||
// Freeze first row
|
||||
$sheet->freezeFirstRow();
|
||||
|
||||
// Freeze the first column
|
||||
$sheet->freezeFirstColumn();
|
||||
|
||||
// Freeze the first row and column
|
||||
$sheet->freezeFirstRowAndColumn();
|
||||
|
||||
// Set freeze
|
||||
$sheet->setFreeze('A2');
|
61
vendor/maatwebsite/excel/docs/export/injection.md
vendored
Normal file
61
vendor/maatwebsite/excel/docs/export/injection.md
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
# NewExcelFile injections
|
||||
|
||||
Following the Laravel 5.0 philosophy with its new awesome FormRequest injections, we introduce you NewExcelFile injections.
|
||||
|
||||
## NewExcelFile class
|
||||
|
||||
This NewExcelFile is a wrapper for a new Excel file. Inside the `getFilename()` you can declare the wanted filename.
|
||||
|
||||
class UserListExport extends \Maatwebsite\Excel\Files\NewExcelFile {
|
||||
|
||||
public function getFilename()
|
||||
{
|
||||
return 'filename';
|
||||
}
|
||||
}
|
||||
|
||||
## Usage
|
||||
|
||||
You can inject these NewExcelFiles inside the __constructor or inside the method (when using Laravel 5.0), in e.g. the controller.
|
||||
|
||||
class ExampleController extends Controller {
|
||||
|
||||
public function exportUserList(UserListExport $export)
|
||||
{
|
||||
// work on the export
|
||||
return $export->sheet('sheetName', function($sheet)
|
||||
{
|
||||
|
||||
})->export('xls');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
## Export Handlers
|
||||
|
||||
To decouple your Excel-export code completely from the controller, you can use the export handlers.
|
||||
|
||||
class ExampleController extends Controller {
|
||||
|
||||
public function exportUserList(UserListExport $export)
|
||||
{
|
||||
// Handle the export
|
||||
$export->handleExport();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
The `handleExport()` method will dynamically call a handler class which is your class name appended with `Handler`
|
||||
|
||||
class UserListExportHandler implements \Maatwebsite\Excel\Files\ExportHandler {
|
||||
|
||||
public function handle(UserListExport $export)
|
||||
{
|
||||
// work on the export
|
||||
return $export->sheet('sheetName', function($sheet)
|
||||
{
|
||||
|
||||
})->export('xls');
|
||||
}
|
||||
|
||||
}
|
19
vendor/maatwebsite/excel/docs/export/merge.md
vendored
Normal file
19
vendor/maatwebsite/excel/docs/export/merge.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Column merging
|
||||
|
||||
### Merging cells
|
||||
|
||||
To merge a range of cells, use `->mergeCells($range)`.
|
||||
|
||||
$sheet->mergeCells('A1:E1');
|
||||
|
||||
### Merging columns and rows
|
||||
|
||||
To merge columns and rows, use `->setMergeColumn($array)`.
|
||||
|
||||
$sheet->setMergeColumn(array(
|
||||
'columns' => array('A','B','C','D'),
|
||||
'rows' => array(
|
||||
array(2,3),
|
||||
array(5,11),
|
||||
)
|
||||
));
|
63
vendor/maatwebsite/excel/docs/export/rows.md
vendored
Normal file
63
vendor/maatwebsite/excel/docs/export/rows.md
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
# Row manipulation
|
||||
|
||||
### Manipulate certain row
|
||||
|
||||
#### Change cell values
|
||||
|
||||
// Manipulate first row
|
||||
$sheet->row(1, array(
|
||||
'test1', 'test2'
|
||||
));
|
||||
|
||||
// Manipulate 2nd row
|
||||
$sheet->row(2, array(
|
||||
'test3', 'test4'
|
||||
));
|
||||
|
||||
#### Manipulate row cells
|
||||
|
||||
// Set black background
|
||||
$sheet->row(1, function($row) {
|
||||
|
||||
// call cell manipulation methods
|
||||
$row->setBackground('#000000');
|
||||
|
||||
});
|
||||
|
||||
### Append row
|
||||
|
||||
// Append row after row 2
|
||||
$sheet->appendRow(2, array(
|
||||
'appended', 'appended'
|
||||
));
|
||||
|
||||
// Append row as very last
|
||||
$sheet->appendRow(array(
|
||||
'appended', 'appended'
|
||||
));
|
||||
|
||||
### Prepend row
|
||||
|
||||
// Add before first row
|
||||
$sheet->prependRow(1, array(
|
||||
'prepended', 'prepended'
|
||||
));
|
||||
|
||||
// Add as very first
|
||||
$sheet->prependRow(array(
|
||||
'prepended', 'prepended'
|
||||
));
|
||||
|
||||
### Append multiple rows
|
||||
|
||||
// Append multiple rows
|
||||
$sheet->rows(array(
|
||||
array('test1', 'test2'),
|
||||
array('test3', 'test4')
|
||||
));
|
||||
|
||||
// Append multiple rows
|
||||
$sheet->rows(array(
|
||||
array('test5', 'test6'),
|
||||
array('test7', 'test8')
|
||||
));
|
50
vendor/maatwebsite/excel/docs/export/sheet-styling.md
vendored
Normal file
50
vendor/maatwebsite/excel/docs/export/sheet-styling.md
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# Sheet styling
|
||||
|
||||
### General styling
|
||||
|
||||
If you want to change the general styling of your sheet (not cell or range specific), you can use the `->setStyle()` method.
|
||||
|
||||
// Set font with ->setStyle()`
|
||||
$sheet->setStyle(array(
|
||||
'font' => array(
|
||||
'name' => 'Calibri',
|
||||
'size' => 15,
|
||||
'bold' => true
|
||||
)
|
||||
));
|
||||
|
||||
### Fonts
|
||||
|
||||
To change the font for the current sheet use `->setFont($array)`:
|
||||
|
||||
$sheet->setFont(array(
|
||||
'family' => 'Calibri',
|
||||
'size' => '15',
|
||||
'bold' => true
|
||||
));
|
||||
|
||||
#### Separate setters
|
||||
|
||||
// Font family
|
||||
$sheet->setFontFamily('Comic Sans MS');
|
||||
|
||||
// Font size
|
||||
$sheet->setFontSize(15);
|
||||
|
||||
// Font bold
|
||||
$sheet->setFontBold(true);
|
||||
|
||||
### Borders
|
||||
|
||||
You can set borders for the sheet, by using:
|
||||
|
||||
// Sets all borders
|
||||
$sheet->setAllBorders('thin');
|
||||
|
||||
// Set border for cells
|
||||
$sheet->setBorder('A1', 'thin');
|
||||
|
||||
// Set border for range
|
||||
$sheet->setBorder('A1:F10', 'thin');
|
||||
|
||||
> Go to the reference guide to see a list of available border styles
|
77
vendor/maatwebsite/excel/docs/export/sheets.md
vendored
Normal file
77
vendor/maatwebsite/excel/docs/export/sheets.md
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
# Sheets
|
||||
|
||||
### Creating a sheet
|
||||
|
||||
To create a new sheet inside our newly created file, use `->sheet('Sheetname')`.
|
||||
|
||||
Excel::create('Filename', function($excel) {
|
||||
|
||||
$excel->sheet('Sheetname', function($sheet) {
|
||||
|
||||
// Sheet manipulation
|
||||
|
||||
});
|
||||
|
||||
})->export('xls');
|
||||
|
||||
|
||||
### Creating multiple sheets
|
||||
|
||||
You can set as many sheets as you like inside the file:
|
||||
|
||||
Excel::create('Filename', function($excel) {
|
||||
|
||||
// Our first sheet
|
||||
$excel->sheet('First sheet', function($sheet) {
|
||||
|
||||
});
|
||||
|
||||
// Our second sheet
|
||||
$excel->sheet('Second sheet', function($sheet) {
|
||||
|
||||
});
|
||||
|
||||
})->export('xls');
|
||||
|
||||
### Changing properties
|
||||
|
||||
There are a couple of properties we can change inside the closure. Most of them are set to the config values by default. See `app/config/packages/maatwebsite/excel/config.php`.
|
||||
|
||||
Excel::create('Filename', function($excel) {
|
||||
|
||||
$excel->sheet('Sheetname', function($sheet) {
|
||||
|
||||
$sheet->setOrientation('landscape');
|
||||
|
||||
});
|
||||
|
||||
})->export('xls');
|
||||
|
||||
> Go to the reference guide to see a list of available properties.
|
||||
|
||||
### Default page margin
|
||||
|
||||
It's possible to set the default page margin inside the config file `excel::export.sheets`.
|
||||
It accepts boolean, single value or array.
|
||||
|
||||
To manually set the page margin you can use: `->setPageMargin()`
|
||||
|
||||
// Set top, right, bottom, left
|
||||
$sheet->setPageMargin(array(
|
||||
0.25, 0.30, 0.25, 0.30
|
||||
));
|
||||
|
||||
// Set all margins
|
||||
$sheet->setPageMargin(0.25);
|
||||
|
||||
### Password protecting a sheet
|
||||
|
||||
A sheet can be password protected with `$sheet->protect()`:
|
||||
|
||||
// Default protect
|
||||
$sheet->protect('password');
|
||||
|
||||
// Advanced protect
|
||||
$sheet->protect('password', function(\PHPExcel_Worksheet_Protection $protection) {
|
||||
$protection->setSort(true);
|
||||
});
|
35
vendor/maatwebsite/excel/docs/export/simple.md
vendored
Normal file
35
vendor/maatwebsite/excel/docs/export/simple.md
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# Simple Excel Export
|
||||
|
||||
### Basics
|
||||
|
||||
A new file can be created using the `create` method with the filename as first parameter.
|
||||
|
||||
Excel::create('Filename');
|
||||
|
||||
To manipulate the creation of the file you can use the callback
|
||||
|
||||
Excel::create('Filename', function($excel) {
|
||||
|
||||
// Call writer methods here
|
||||
|
||||
});
|
||||
|
||||
### Changing properties
|
||||
|
||||
There are a couple of properties we can change inside the closure. Most of them are set to the config values by default. See `app/config/packages/maatwebsite/excel/config.php`.
|
||||
|
||||
Excel::create('Filename', function($excel) {
|
||||
|
||||
// Set the title
|
||||
$excel->setTitle('Our new awesome title');
|
||||
|
||||
// Chain the setters
|
||||
$excel->setCreator('Maatwebsite')
|
||||
->setCompany('Maatwebsite');
|
||||
|
||||
// Call them separately
|
||||
$excel->setDescription('A demonstration to change the file properties');
|
||||
|
||||
});
|
||||
|
||||
> Go to the reference guide to see a list of available properties.
|
41
vendor/maatwebsite/excel/docs/export/sizing.md
vendored
Normal file
41
vendor/maatwebsite/excel/docs/export/sizing.md
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# Cell size
|
||||
|
||||
### Set column width
|
||||
|
||||
To set the column width use `->setWidth($cell, $width)`.
|
||||
|
||||
// Set width for a single column
|
||||
$sheet->setWidth('A', 5);
|
||||
|
||||
// Set width for multiple cells
|
||||
$sheet->setWidth(array(
|
||||
'A' => 5,
|
||||
'B' => 10
|
||||
));
|
||||
|
||||
### Set row height
|
||||
|
||||
To set the row height use `->setHeight($row, $height)`.
|
||||
|
||||
// Set height for a single row
|
||||
$sheet->setHeight(1, 50);
|
||||
|
||||
// Set height for multiple rows
|
||||
$sheet->setHeight(array(
|
||||
1 => 50,
|
||||
2 => 25
|
||||
));
|
||||
|
||||
### Set cell size
|
||||
|
||||
To set the cell size use `->setSize($cell, $width, $height)`.
|
||||
|
||||
// Set size for a single cell
|
||||
$sheet->setSize('A1', 500, 50);
|
||||
|
||||
$sheet->setSize(array(
|
||||
'A1' => array(
|
||||
'width' => 50
|
||||
'height' => 500,
|
||||
)
|
||||
));
|
39
vendor/maatwebsite/excel/docs/export/store.md
vendored
Normal file
39
vendor/maatwebsite/excel/docs/export/store.md
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# Store on server
|
||||
|
||||
To store the created file on the server, use `->store($ext, $path = false, $returnInfo = false)` or `->save()`.
|
||||
|
||||
### Normal export to default storage path
|
||||
|
||||
By default the file will be stored inside the `app/storage/exports` folder, which has been defined in the `export.php` config file.
|
||||
|
||||
Excel::create('Filename', function($excel) {
|
||||
|
||||
// Set sheets
|
||||
|
||||
})->store('xls');
|
||||
|
||||
### Normal export to custom storage path
|
||||
|
||||
If you want to use a custom storage path (e.g. to separate the files per client), you can set the folder as the second parameter.
|
||||
|
||||
->store('xls', storage_path('excel/exports'));
|
||||
|
||||
### Store and export
|
||||
|
||||
->store('xls')->export('xls');
|
||||
|
||||
### Store and return storage info
|
||||
|
||||
If you want to return storage information, set the third paramter to true or change the config setting inside `export.php`.
|
||||
|
||||
->store('xls', false, true);
|
||||
|
||||
|Key|Explanation|
|
||||
|---|-----------|
|
||||
|**full**| Full path with filename
|
||||
|**path**| Path without filename
|
||||
|**file**| Filename
|
||||
|**title**| File title
|
||||
|**ext**| File extension
|
||||
|
||||
> Make sure your storage folder is **writable**!
|
42
vendor/maatwebsite/excel/docs/formats.md
vendored
Normal file
42
vendor/maatwebsite/excel/docs/formats.md
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
PHPExcel_Style_NumberFormat::FORMAT_GENERAL = 'General'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_TEXT = '@'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_NUMBER = '0'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_NUMBER_00 = '0.00'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1 = '#,##0.00'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2 = '#,##0.00_-'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE = '0%'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 = '0.00%'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2 = 'yyyy-mm-dd'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD = 'yy-mm-dd'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY = 'dd/mm/yy'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYSLASH = 'd/m/y'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYMINUS = 'd-m-y'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_DMMINUS = 'd-m'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_MYMINUS = 'm-y'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX14 = 'mm-dd-yy'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15 = 'd-mmm-yy'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX16 = 'd-mmm'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX17 = 'mmm-yy'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22 = 'm/d/yy h:mm'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME = 'd/m/y h:mm'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME1 = 'h:mm AM/PM'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME2 = 'h:mm:ss AM/PM'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 = 'h:mm'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 = 'h:mm:ss'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME5 = 'mm:ss'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME6 = 'h:mm:ss'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME7 = 'i:s.S'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME8 = 'h:mm:ss;@'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH = 'yy/mm/dd;@'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE = '"$"#,##0.00_-'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD = '$#,##0_-'
|
||||
PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE = '[$EUR ]#,##0.00_-'
|
||||
|
||||
->setColumnFormat(array(
|
||||
'B' => '0',
|
||||
'D' => '0.00',
|
||||
'F' => '@',
|
||||
'F' => 'yyyy-mm-dd',
|
||||
......
|
||||
)
|
||||
)
|
5
vendor/maatwebsite/excel/docs/getting-started.md
vendored
Normal file
5
vendor/maatwebsite/excel/docs/getting-started.md
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
@include:Installation|installation
|
||||
@include:Config|config
|
||||
@include:Requirements|requirements
|
||||
@include:Contributing|contributing
|
||||
@include:License|license
|
18
vendor/maatwebsite/excel/docs/getting-started/config.md
vendored
Normal file
18
vendor/maatwebsite/excel/docs/getting-started/config.md
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
#Config
|
||||
|
||||
### Laravel 4
|
||||
|
||||
Laravel Excel includes several config settings for import-, export-, view- and CSV-specific settings.
|
||||
Use the artisan publish command to publish the config file to your project.
|
||||
|
||||
php artisan config:publish maatwebsite/excel
|
||||
|
||||
The config files can now be found at `app/config/packages/maatwebsite/excel`
|
||||
|
||||
### Laravel 5
|
||||
|
||||
To publish the config settings in Laravel 5 use:
|
||||
|
||||
php artisan vendor:publish
|
||||
|
||||
This will add an `excel.php` config file to your config folder.
|
22
vendor/maatwebsite/excel/docs/getting-started/contributing.md
vendored
Normal file
22
vendor/maatwebsite/excel/docs/getting-started/contributing.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# Contribution Guide
|
||||
|
||||
### Bug fixes
|
||||
|
||||
**ALL** bug fixes should be made to appropriate branch (e.g. `1.1` for 1.1.* bug fixes). Bug fixes should never be sent to the `master` branch.
|
||||
|
||||
### Pull Requests
|
||||
|
||||
Every pull request should pass the unit tests. If you include new functionality, make sure you include a test. Pull requests will be evaluated and possibly added to the next stable release.
|
||||
|
||||
### Feature Requests
|
||||
|
||||
If you have an idea for a new feature you would like to see added to Laravel Excel, you may create an issue on GitHub with `[Request]` in the title. The feature request will then be reviewed by @Maatwebsite.
|
||||
|
||||
### Coding Guidelines
|
||||
|
||||
Laravel, and therefore Maatwebsite's Laravel Excel follows the [PSR-0](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md) and [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) coding standards. In addition to these standards, below is a list of other coding standards that should be followed:
|
||||
|
||||
- Namespace declarations should be on the same line as `<?php`.
|
||||
- Class opening `{` should be on the same line as the class name.
|
||||
- Function and control structure opening `{` should be on a separate line.
|
||||
- Interface and Trait names are suffixed with `Interface` (`FooInterface`) and `Trait` (`FooTrait`) respectively.
|
23
vendor/maatwebsite/excel/docs/getting-started/installation.md
vendored
Normal file
23
vendor/maatwebsite/excel/docs/getting-started/installation.md
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
#Installation
|
||||
|
||||
Require this package in your `composer.json` and update composer. This will download the package and PHPExcel of PHPOffice.
|
||||
|
||||
#### Laravel 4
|
||||
|
||||
"maatwebsite/excel": "~1.3"
|
||||
|
||||
#### Laravel 5
|
||||
|
||||
"maatwebsite/excel": "~2.1.0"
|
||||
|
||||
After updating composer, add the ServiceProvider to the providers array in `app/config/app.php`
|
||||
|
||||
'Maatwebsite\Excel\ExcelServiceProvider',
|
||||
|
||||
You can use the facade for shorter code. Add this to your aliasses:
|
||||
|
||||
'Excel' => 'Maatwebsite\Excel\Facades\Excel',
|
||||
|
||||
The class is binded to the ioC as `excel`
|
||||
|
||||
$excel = App::make('excel');
|
3
vendor/maatwebsite/excel/docs/getting-started/license.md
vendored
Normal file
3
vendor/maatwebsite/excel/docs/getting-started/license.md
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#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!
|
8
vendor/maatwebsite/excel/docs/getting-started/requirements.md
vendored
Normal file
8
vendor/maatwebsite/excel/docs/getting-started/requirements.md
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Requirements
|
||||
|
||||
- PHP version >= 5.3.7
|
||||
- Laravel >= 4.1
|
||||
- PHPOffice PHPExcel >= 1.8.0 (included by composer.json)
|
||||
- PHP extension php_zip enabled (required if you need PHPExcel to handle .xlsx .ods or .gnumeric files)
|
||||
- PHP extension php_xml enabled
|
||||
- PHP extension php_gd2 enabled (optional, but required for exact column width autocalculation)
|
14
vendor/maatwebsite/excel/docs/import.md
vendored
Normal file
14
vendor/maatwebsite/excel/docs/import.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
@include:Importing a file|basics
|
||||
@include:ExcelFile injections|injection
|
||||
@include:Handling results|results
|
||||
@include:Selecting sheets and columns|select
|
||||
@include:Dates|dates
|
||||
@include:Calculation|calculation
|
||||
@include:Custom formatting values|formatting
|
||||
@include:Caching and cell caching|cache
|
||||
@include:Chunk importing|chunk
|
||||
@include:Batch import|batch
|
||||
@include:Import by config|config
|
||||
@include:Edit existing files|edit
|
||||
@include:Converting|convert
|
||||
@include:Extra|extra
|
9
vendor/maatwebsite/excel/docs/import/basics.md
vendored
Normal file
9
vendor/maatwebsite/excel/docs/import/basics.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Importing a file
|
||||
|
||||
To start importing a file, you can use `->load($filename)`. The callback is optional.
|
||||
|
||||
Excel::load('file.xls', function($reader) {
|
||||
|
||||
// reader methods
|
||||
|
||||
});
|
43
vendor/maatwebsite/excel/docs/import/batch.md
vendored
Normal file
43
vendor/maatwebsite/excel/docs/import/batch.md
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
#Batch import
|
||||
|
||||
### Import a folder
|
||||
|
||||
To import an entire folder (only xls, xlsx and csv files will be imported), set the folder as the first parameter.
|
||||
|
||||
Excel::batch('app/storage/uploads', function($rows, $file) {
|
||||
|
||||
// Explain the reader how it should interpret each row,
|
||||
// for every file inside the batch
|
||||
$rows->each(function($row) {
|
||||
|
||||
// Example: dump the firstname
|
||||
dd($row->firstname);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
### Import multiple files
|
||||
|
||||
It's also possible to provide an array of files to import.
|
||||
|
||||
$files = array(
|
||||
'file1.xls',
|
||||
'file2.xls'
|
||||
);
|
||||
|
||||
Excel::batch($files, function($rows, $file) {
|
||||
|
||||
});
|
||||
|
||||
### Import a folder and multiple sheets
|
||||
|
||||
When your files contain multiple sheets, you should also loop the sheets
|
||||
|
||||
Excel::batch('app/storage/uploads', function($sheets, $file) {
|
||||
|
||||
$sheets->each(function($sheet) {
|
||||
|
||||
});
|
||||
|
||||
});
|
12
vendor/maatwebsite/excel/docs/import/cache.md
vendored
Normal file
12
vendor/maatwebsite/excel/docs/import/cache.md
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# Caching and Cell caching
|
||||
|
||||
### Cell caching
|
||||
|
||||
You can enable cell caching inside the config `cache.php`. You can choose between a couple of drivers and change a couple of settings. By default the caching is **enabled** and will use **in memory** caching.
|
||||
|
||||
### Remembering results
|
||||
|
||||
If you want to remember the results you can use `->remember($minutes)`. Next time you will load the same file (if it's still inside the cache), it will return the cached results.
|
||||
|
||||
// Remember for 10 minutes
|
||||
$results = $reader->remember(10)->get();
|
11
vendor/maatwebsite/excel/docs/import/calculation.md
vendored
Normal file
11
vendor/maatwebsite/excel/docs/import/calculation.md
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Calculate formulas
|
||||
|
||||
By default formulas inside the file are being calculated and it's result will be returned. Inside `import.php` config you can change the default behaviour by setting `calculate` to the desired preference.
|
||||
|
||||
If you want to enable/disable it for a single import, you can use `->calculate($boolean)`
|
||||
|
||||
// Enable calculation
|
||||
$reader->calculate();
|
||||
|
||||
// Disable calculation
|
||||
$reader->calculate(false);
|
49
vendor/maatwebsite/excel/docs/import/chunk.md
vendored
Normal file
49
vendor/maatwebsite/excel/docs/import/chunk.md
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
# Chunk importer
|
||||
|
||||
When dealing with big files, it's better to import the data in big chunks. You can enable this with `filter('chunk')`;
|
||||
To import it into chunks you can use `chunk($size, $callback)` instead of the normal `get()`. The first parameter is the size of the chunk. The second parameter is a closure which will return the results.
|
||||
|
||||
Excel::filter('chunk')->load('file.csv')->chunk(250, function($results)
|
||||
{
|
||||
foreach($results as $row)
|
||||
{
|
||||
// do stuff
|
||||
}
|
||||
});
|
||||
|
||||
## ExcelFile class example:
|
||||
|
||||
When working with ExcelFile injections (in the constructor or as method injection), you can enable the chunk filter inside the ExcelFile class
|
||||
|
||||
class UserListImport extends \Maatwebsite\Excel\Files\ExcelFile {
|
||||
|
||||
public function getFile()
|
||||
{
|
||||
return 'file.csv';
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
{
|
||||
return [
|
||||
'chunk'
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Injected ExcelFile example:
|
||||
|
||||
public function importUserList(UserListImport $import)
|
||||
{
|
||||
$import->chunk(250, function($results)
|
||||
{
|
||||
// do stuff
|
||||
// or return true if you want to stop importing.
|
||||
});
|
||||
}
|
||||
|
||||
## Queued chunks
|
||||
|
||||
We automatically queue every chunk for you, if you have enabled the queue driver in your config.
|
||||
|
||||
If you want to by-pass the behaviour, you can pass `false` as third param of `chunk($size, $callback, $shouldQueue)`.
|
15
vendor/maatwebsite/excel/docs/import/config.md
vendored
Normal file
15
vendor/maatwebsite/excel/docs/import/config.md
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# Import by Config
|
||||
|
||||
When using advanced Excel files (e.g. without any heading columns), it can be complicated to import these.
|
||||
`->byConfig()` will help you handle this problem.
|
||||
|
||||
Inside `excel::import.sheets` config you can find an example.
|
||||
|
||||
Excel::load('file.xls')->byConfig('excel::import.sheets', function($sheet) {
|
||||
|
||||
// The firstname getter will correspond with a cell coordinate set inside the config
|
||||
$firstname = $sheet->firstname;
|
||||
|
||||
});
|
||||
|
||||
> **Note:** if you are using multiple sheets. `->byConfig` will loop through all sheets. If these getters are only exist on one sheet, you can always use `->selectSheets()`.
|
9
vendor/maatwebsite/excel/docs/import/convert.md
vendored
Normal file
9
vendor/maatwebsite/excel/docs/import/convert.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Converting
|
||||
|
||||
You can convert from one filetype to another by using `->convert()`
|
||||
|
||||
Excel::load('file.csv', function($file) {
|
||||
|
||||
// modify stuff
|
||||
|
||||
})->convert('xls');
|
45
vendor/maatwebsite/excel/docs/import/dates.md
vendored
Normal file
45
vendor/maatwebsite/excel/docs/import/dates.md
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
# Dates
|
||||
|
||||
By default the dates will be parsed as a **[Carbon object](https://github.com/briannesbitt/Carbon)**. You can disable date formatting completly inside `import.php` by setting `dates.enabled` to `false`.
|
||||
|
||||
To enable/disable date formatting for a single import, use `->formatDates($boolean, $format)`
|
||||
|
||||
// Format the dates
|
||||
$reader->formatDates(true);
|
||||
|
||||
// Disable date formatting
|
||||
$reader->formatDates(false);
|
||||
|
||||
// Format dates + set date format
|
||||
$reader->formatDates(true, 'Y-m-d');
|
||||
|
||||
### Format dates
|
||||
|
||||
By default the dates are **not formatted**, but returned as a Carbon object. There are a couple of options to format them.
|
||||
|
||||
#### Formatting results after ->get()
|
||||
|
||||
Inside your loop you can utilise the Carbon method `->format($dateFormat)`
|
||||
|
||||
$rows->each(function($row) {
|
||||
|
||||
$created_at = $row->created_at->format('Y-m-d');
|
||||
|
||||
});
|
||||
|
||||
#### Setting a default date format
|
||||
|
||||
Inside the config you can set a default date format. A Carbon object will no longer be returned.
|
||||
|
||||
Or you can use `->setDateFormat()`
|
||||
|
||||
$reader->setDateFormat('Y-m-d');
|
||||
|
||||
### Setting custom date columns
|
||||
|
||||
Cells which are not Excel formatted dates will not be parsed as a date. To force this behaviour (or to use this with CSV imports), you can set these date columns manually: `->setDateColumns()`
|
||||
|
||||
$reader->setDateColumns(array(
|
||||
'created_at',
|
||||
'deleted_at'
|
||||
))->get();
|
9
vendor/maatwebsite/excel/docs/import/edit.md
vendored
Normal file
9
vendor/maatwebsite/excel/docs/import/edit.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Editing existing files
|
||||
|
||||
You can edit existing Excel files, by loading them and after modification exporting them.
|
||||
|
||||
Excel::load('file.csv', function($file) {
|
||||
|
||||
// modify stuff
|
||||
|
||||
})->export('csv');
|
44
vendor/maatwebsite/excel/docs/import/extra.md
vendored
Normal file
44
vendor/maatwebsite/excel/docs/import/extra.md
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# Extra
|
||||
|
||||
### Disable using first row as collection attributes
|
||||
|
||||
By default we will use the first row of a file as table heading (so as attribute names for the collection).
|
||||
You can change the default behaviour inside `import.php` with `import.heading`.
|
||||
|
||||
To disable this for a single import, use `->noHeading()`.
|
||||
|
||||
$reader->noHeading();
|
||||
|
||||
### Setting the cell name separator
|
||||
By default collection attribute names will be set by looking at the first row columns. Spaces will be translated to `_`.
|
||||
|
||||
**E.g. Created at -> created_at**
|
||||
|
||||
The default behaviour can be changed inside the `import.php` config by changing `'separator'`. Or you can use `->setSeparator($separator)`.
|
||||
|
||||
$reader->setSeparator('-');
|
||||
|
||||
### Ignoring empty cells
|
||||
By default empty cells will not be ignored and presented as null inside the cell collection.
|
||||
|
||||
To change the default behaviour, you can change `'ignoreEmpty`' inside `import.php` or use `->ignoreEmpty()`.
|
||||
|
||||
$reader->ignoreEmpty();
|
||||
|
||||
### Input encoding
|
||||
|
||||
Inside the `import.php` config you can change the input encoding. In most cases **UTF-8** will be the best solution. Hower if you dump your results make sure your HTML page has this exact same meta charset!
|
||||
|
||||
Optionally you can pass the input encoding inside the `->load()` method.
|
||||
|
||||
// When utilising a closure, you can pass the input encoding as third parameter.
|
||||
Excel::load('filename.csv', function($reader) {
|
||||
|
||||
}, 'UTF-8');
|
||||
|
||||
// or without a closure, you can use it as second parameter.
|
||||
Excel::load('filename.csv', 'UTF-8');
|
||||
|
||||
### CSV Settings
|
||||
|
||||
Inside the `csv.php` config you can change the default settings, like the `delimiter`, the `enclosure` and the `line_ending`.
|
38
vendor/maatwebsite/excel/docs/import/formatting.md
vendored
Normal file
38
vendor/maatwebsite/excel/docs/import/formatting.md
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# Custom formatting values
|
||||
|
||||
By default Laravel Excel uses PHPExcel's default value binder to intelligently format a cells value when reading it. You may override this behavior by passing in your own value binder to suit your specific needs. Value binders must implement PHPExcel_Cell_IValueBinder and have a bindValue method. They may also extend PHPExcel_Cell_DefaultValueBinder to return the default behavior.
|
||||
|
||||
use PHPExcel_Cell;
|
||||
use PHPExcel_Cell_DataType;
|
||||
use PHPExcel_Cell_IValueBinder;
|
||||
use PHPExcel_Cell_DefaultValueBinder;
|
||||
|
||||
class MyValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||
{
|
||||
public function bindValue(PHPExcel_Cell $cell, $value = null)
|
||||
{
|
||||
if (is_numeric($value))
|
||||
{
|
||||
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// else return default behavior
|
||||
return parent::bindValue($cell, $value);
|
||||
}
|
||||
}
|
||||
|
||||
$myValueBinder = new MyValueBinder;
|
||||
|
||||
Excel::setValueBinder($myValueBinder)->load('file.xls', function($reader) {
|
||||
|
||||
// reader methods
|
||||
|
||||
});
|
||||
|
||||
Available PHPExcel_Cell_DataType's are TYPE_STRING, TYPE_FORMULA, TYPE_NUMERIC, TYPE_BOOL, TYPE_NULL, TYPE_INLINE and TYPE_ERROR
|
||||
|
||||
To reset the value binder back to default and/or before calling Laravel Excel after setting a custom value binder you need to call the resetValueBinder method.
|
||||
|
||||
Excel::resetValueBinder();
|
87
vendor/maatwebsite/excel/docs/import/injection.md
vendored
Normal file
87
vendor/maatwebsite/excel/docs/import/injection.md
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
# ExcelFile injections
|
||||
|
||||
Following the Laravel 5.0 philosophy with its new awesome FormRequest injections, we introduce you ExcelFile injections.
|
||||
|
||||
## ExcelFile class
|
||||
|
||||
This class is a wrapper for a file on your server. Inside the `getFile()` method you return the filename and it's location. Inside the `getFilters()` method you can enable filters, like the chunk filter.
|
||||
|
||||
class UserListImport extends \Maatwebsite\Excel\Files\ExcelFile {
|
||||
|
||||
public function getFile()
|
||||
{
|
||||
return storage_path('exports') . '/file.csv';
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
{
|
||||
return [
|
||||
'chunk'
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
If you want to have the `getFile()` dynamic based on user's input, you can easily do:
|
||||
|
||||
public function getFile()
|
||||
{
|
||||
// Import a user provided file
|
||||
$file = Input::file('report');
|
||||
$filename = $this->doSomethingLikeUpload($file);
|
||||
|
||||
// Return it's location
|
||||
return $filename;
|
||||
}
|
||||
|
||||
## Usage
|
||||
|
||||
You can inject these ExcelFiles inside the __constructor or inside the method (when using Laravel 5.0), in e.g. the controller.
|
||||
|
||||
class ExampleController extends Controller {
|
||||
|
||||
public function importUserList(UserListImport $import)
|
||||
{
|
||||
// get the results
|
||||
$results = $import->get();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
## CSV Settings
|
||||
|
||||
You can pass through optional CSV settings, like `$delimiter`, `$enclosure` and `$lineEnding` as protected properties of the class.
|
||||
|
||||
class UserListImport extends \Maatwebsite\Excel\Files\ExcelFile {
|
||||
|
||||
protected $delimiter = ',';
|
||||
protected $enclosure = '"';
|
||||
protected $lineEnding = '\r\n';
|
||||
|
||||
}
|
||||
|
||||
## Import Handlers
|
||||
|
||||
To decouple your Excel-import code completely from the controller, you can use the import handlers.
|
||||
|
||||
class ExampleController extends Controller {
|
||||
|
||||
public function importUserList(UserListImport $import)
|
||||
{
|
||||
// Handle the import
|
||||
$import->handleImport();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
The `handleImport()` method will dynamically call a handler class which is your class name appended with `Handler`
|
||||
|
||||
class UserListImportHandler implements \Maatwebsite\Excel\Files\ImportHandler {
|
||||
|
||||
public function handle(UserListImport $import)
|
||||
{
|
||||
// get the results
|
||||
$results = $import->get();
|
||||
}
|
||||
|
||||
}
|
126
vendor/maatwebsite/excel/docs/import/results.md
vendored
Normal file
126
vendor/maatwebsite/excel/docs/import/results.md
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
# Handling imported results
|
||||
|
||||
### Getting all sheets and rows
|
||||
|
||||
After you have loaded a file, you can `->get()` the results like so:
|
||||
|
||||
Excel::load('file.xls', function($reader) {
|
||||
|
||||
})->get();
|
||||
|
||||
or
|
||||
|
||||
Excel::load('file.xls', function($reader) {
|
||||
|
||||
// Getting all results
|
||||
$results = $reader->get();
|
||||
|
||||
// ->all() is a wrapper for ->get() and will work the same
|
||||
$results = $reader->all();
|
||||
|
||||
});
|
||||
|
||||
> The `->get()` and `->all()` methods will return a sheet or row collection, depending on the amount of sheets the file has. You can disable this feature inside the `import.php` config by setting `'force_sheets_collection'` to `true`. When set to true it will always return a sheet collection.
|
||||
|
||||
### Table heading as attributes
|
||||
|
||||
By default the first row of the excel file will be used as attributes.
|
||||
|
||||
// Get the firstname
|
||||
$row->firstname;
|
||||
|
||||
> **Note**: by default these attributes will be converted to a slug. You can change the default inside the config `excel::import.heading`. Available options are: `true|false|slugged|ascii|numeric|hashed|trans|original`
|
||||
|
||||
> True and slugged will be converted to ASCII as well when `excel::import.to_ascii` is set to true. You can change the default separator as well inside the config.
|
||||
|
||||
### Collections
|
||||
|
||||
Sheets, rows and cells are collections, this means after doing a `->get()` you can use all default collection methods.
|
||||
|
||||
// E.g. group the results
|
||||
$reader->get()->groupBy('firstname');
|
||||
|
||||
### Getting the first sheet or row
|
||||
|
||||
To get the first sheet or row, you can utilise `->first()`.
|
||||
|
||||
$reader->first();
|
||||
|
||||
> **Note:** depending on the config `'force_sheets_collection'` it will return the first row or sheet.
|
||||
|
||||
### Workbook and sheet title
|
||||
|
||||
It's possible to retrieve the workbook and sheet title with `->getTitle()`.
|
||||
|
||||
// Get workbook title
|
||||
$workbookTitle = $reader->getTitle();
|
||||
|
||||
foreach($reader as $sheet)
|
||||
{
|
||||
// get sheet title
|
||||
$sheetTitle = $sheet->getTitle();
|
||||
}
|
||||
|
||||
### Limiting the results
|
||||
|
||||
##### Taking rows
|
||||
|
||||
When you only want to return the first x rows of a sheet, you can use `->take()` or `->limit()`.
|
||||
|
||||
// You can either use ->take()
|
||||
$reader->take(10);
|
||||
|
||||
// Or ->limit()
|
||||
$reader->limit(10);
|
||||
|
||||
##### Skipping rows
|
||||
|
||||
When you want to skip a certain amount of rows you can use `->skip()` or `->limit(false, 10)`
|
||||
|
||||
// Skip 10 results
|
||||
$reader->skip(10);
|
||||
|
||||
// Skip 10 results with limit, but return all other rows
|
||||
$reader->limit(false, 10);
|
||||
|
||||
// Skip and take
|
||||
$reader->skip(10)->take(10);
|
||||
|
||||
// Limit with skip and take
|
||||
$reader->($skip, $take);
|
||||
|
||||
### Result mutators
|
||||
|
||||
When you want to get an array instead of an object, you can use `->toArray()`.
|
||||
|
||||
$reader->toArray();
|
||||
|
||||
When you want an object, you can alternativly (instead of get() or all()) use `->toObject()`.
|
||||
|
||||
$reader->toObject();
|
||||
|
||||
### Displaying results
|
||||
|
||||
You can dump the results to a readable output by using `->dump()` or `->dd()`.
|
||||
|
||||
// Dump the results
|
||||
$reader->dump();
|
||||
|
||||
// Dump results and die
|
||||
$reader->dd();
|
||||
|
||||
### Iterating the results
|
||||
|
||||
You can iterate the results by using `->each()`.
|
||||
|
||||
// Loop through all sheets
|
||||
$reader->each(function($sheet) {
|
||||
|
||||
// Loop through all rows
|
||||
$sheet->each(function($row) {
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
> Alternatively you can also `foreach` the results.
|
31
vendor/maatwebsite/excel/docs/import/select.md
vendored
Normal file
31
vendor/maatwebsite/excel/docs/import/select.md
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# Selecting sheets and columns
|
||||
|
||||
### Selecting one specific sheet
|
||||
If you want to select a single sheet, you can use `->selectSheets($name)`. Only that sheet will be loaded.
|
||||
|
||||
Excel::selectSheets('sheet1')->load();
|
||||
|
||||
### Selecting multiple sheets
|
||||
If you want to select multiple sheets inside your file, you can pass an array as the parameter;
|
||||
|
||||
Excel::selectSheets('sheet1', 'sheet2')->load();
|
||||
|
||||
### Selecting sheets by index
|
||||
|
||||
// First sheet
|
||||
Excel::selectSheetsByIndex(0)->load();
|
||||
|
||||
// First and second sheet
|
||||
Excel::selectSheetsByIndex(0, 1)->load();
|
||||
|
||||
### Selecting columns
|
||||
|
||||
If you want to select only a couple of columns, you can use `->select($columns)` or pass an array as the first parameter of `->get($columns)`.
|
||||
|
||||
// Select
|
||||
$reader->select(array('firstname', 'lastname'))->get();
|
||||
|
||||
// Or
|
||||
$reader->get(array('firstname', 'lastname'));
|
||||
|
||||
> All get methods (like all(), first(), dump(), toArray(), ...) accept an array of columns.
|
8
vendor/maatwebsite/excel/docs/merge.md
vendored
Normal file
8
vendor/maatwebsite/excel/docs/merge.md
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
$mergeColumn = array(
|
||||
* 'columns' => array('A','B','C','D'),
|
||||
* 'rows' => array(
|
||||
* array(2,3),
|
||||
* array(5,11),
|
||||
* .....
|
||||
* )
|
||||
* );
|
6
vendor/maatwebsite/excel/docs/reference-guide.md
vendored
Normal file
6
vendor/maatwebsite/excel/docs/reference-guide.md
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
@include:Available file properties|file-properties
|
||||
@include:Available sheet properties|sheet-properties
|
||||
@include:Available CSS styles|css-styles
|
||||
@include:Available border styles|borders
|
||||
@include:Available column formatting|formatting
|
||||
@include:Closures|closures
|
18
vendor/maatwebsite/excel/docs/reference-guide/borders.md
vendored
Normal file
18
vendor/maatwebsite/excel/docs/reference-guide/borders.md
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# Available border styles
|
||||
|
||||
| Style name | PHPExcel class reference|
|
||||
| ------------- |-----------------|
|
||||
|none|PHPExcel_Style_Border::BORDER_NONE
|
||||
|dashDot|PHPExcel_Style_Border::BORDER_DASHDOT
|
||||
| dashDotDot|PHPExcel_Style_Border::BORDER_DASHDOTDOT
|
||||
| dashed |PHPExcel_Style_Border::BORDER_DASHED
|
||||
| dotted |PHPExcel_Style_Border::BORDER_DOTTED
|
||||
| double |PHPExcel_Style_Border::BORDER_DOUBLE
|
||||
| hair |PHPExcel_Style_Border::BORDER_HAIR
|
||||
| medium |PHPExcel_Style_Border::BORDER_MEDIUM
|
||||
| mediumDashDot |PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT
|
||||
| mediumDashDotDot |PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT
|
||||
| mediumDashed |PHPExcel_Style_Border::BORDER_MEDIUMDASHED
|
||||
| slantDashDot |PHPExcel_Style_Border::BORDER_SLANTDASHDOT
|
||||
| thick|PHPExcel_Style_Border::BORDER_THICK
|
||||
| thin|PHPExcel_Style_Border::BORDER_THIN
|
10
vendor/maatwebsite/excel/docs/reference-guide/closures.md
vendored
Normal file
10
vendor/maatwebsite/excel/docs/reference-guide/closures.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# Closures
|
||||
|
||||
| Method | Closure class |
|
||||
| ------------- |-------------|
|
||||
| create() | Maatwebsite\Excel\Writers\LaravelExcelWriter |
|
||||
| load() | Maatwebsite\Excel\Readers\LaravelExcelReader |
|
||||
| batch | Maatwebsite\Excel\Readers\Batch |
|
||||
| sheet() | Maatwebsite\Excel\Classes\LaravelExcelWorksheet |
|
||||
| cells() | Maatwebsite\Excel\Writers\CellWriter |
|
||||
| row() | Maatwebsite\Excel\Writers\CellWriter |
|
19
vendor/maatwebsite/excel/docs/reference-guide/css-styles.md
vendored
Normal file
19
vendor/maatwebsite/excel/docs/reference-guide/css-styles.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Available CSS styles
|
||||
|
||||
Styles that can be used inside an external CSS file or as inline CSS.
|
||||
|
||||
| Style name | Example Value |
|
||||
| ------------- |-------------|
|
||||
| background(-color) | #000000 |
|
||||
| color | #FFFFFF |
|
||||
| font-weight | bold |
|
||||
| font-style | italic |
|
||||
| font-weight | bold |
|
||||
| font-size | 20px |
|
||||
| font-family | Open Sans |
|
||||
| text-decoration | underline |
|
||||
| text-align | center |
|
||||
| vertical-align | middle |
|
||||
| border(-*) | 1px dashed #CCC |
|
||||
| width | 100(px) |
|
||||
| height | 1100(px) |
|
15
vendor/maatwebsite/excel/docs/reference-guide/file-properties.md
vendored
Normal file
15
vendor/maatwebsite/excel/docs/reference-guide/file-properties.md
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# Available file properties
|
||||
|
||||
Properties that can be set with `$excel->set{$property}()`
|
||||
|
||||
| Property name |
|
||||
| ------------- |
|
||||
|creator
|
||||
|lastModifiedBy
|
||||
|title
|
||||
|description
|
||||
|subject
|
||||
|keywords
|
||||
|category
|
||||
|manager
|
||||
|company
|
37
vendor/maatwebsite/excel/docs/reference-guide/formatting.md
vendored
Normal file
37
vendor/maatwebsite/excel/docs/reference-guide/formatting.md
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
# Available column formatting
|
||||
|
||||
| Format name | PHPExcel class reference|
|
||||
| ------------- |-----------------|
|
||||
|General|PHPExcel_Style_NumberFormat::FORMAT_GENERAL
|
||||
|@|PHPExcel_Style_NumberFormat::FORMAT_TEXT
|
||||
|0|PHPExcel_Style_NumberFormat::FORMAT_NUMBER
|
||||
|0.00|PHPExcel_Style_NumberFormat::FORMAT_NUMBER_00
|
||||
|#,##0.00|PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1
|
||||
|#,##0.00_-|PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2
|
||||
|0%|PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE
|
||||
|0.00%|PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00
|
||||
|yyyy-mm-dd|PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2
|
||||
|yy-mm-dd|PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD
|
||||
|dd/mm/yy|PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY
|
||||
|d/m/y|PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYSLASH
|
||||
|d-m-y|PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYMINUS
|
||||
|d-m|PHPExcel_Style_NumberFormat::FORMAT_DATE_DMMINUS
|
||||
|m-y|PHPExcel_Style_NumberFormat::FORMAT_DATE_MYMINUS
|
||||
|mm-dd-yy|PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX14
|
||||
|d-mmm-yy|PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15
|
||||
|d-mmm|PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX16
|
||||
|mmm-yy|PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX17
|
||||
|m/d/yy h:mm|PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22
|
||||
|d/m/y h:mm|PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME
|
||||
|h:mm AM/PM|PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME1
|
||||
|h:mm:ss AM/PM|PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME2
|
||||
|h:mm|PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3
|
||||
|h:mm:ss|PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4
|
||||
|mm:ss|PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME5
|
||||
|h:mm:ss|PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME6
|
||||
|i:s.S|PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME7
|
||||
|h:mm:ss;@|PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME8
|
||||
|yy/mm/dd;@|PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH
|
||||
|"$"#,##0.00_-|PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE
|
||||
|$#,##0_-|PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD
|
||||
|[$EUR ]#,##0.00_-|PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE
|
18
vendor/maatwebsite/excel/docs/reference-guide/sheet-properties.md
vendored
Normal file
18
vendor/maatwebsite/excel/docs/reference-guide/sheet-properties.md
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# Available sheet properties
|
||||
|
||||
Properties that can be set with `$sheet->set{$property}()`
|
||||
|
||||
| Property name | Possible value|
|
||||
| ------------- |-----------------|
|
||||
|orientation| string
|
||||
|paperSize| integer
|
||||
|scale| integer
|
||||
|fitToPage| boolean
|
||||
|fitToHeight| boolean
|
||||
|fitToWidth| boolean
|
||||
|columnsToRepeatAtLeft| array
|
||||
|rowsToRepeatAtTop| array
|
||||
|horizontalCentered| boolean
|
||||
|verticalCentered| boolean
|
||||
|printArea| range
|
||||
|firstPageNumber| integer
|
1
vendor/maatwebsite/excel/dump.rdb
vendored
Normal file
1
vendor/maatwebsite/excel/dump.rdb
vendored
Normal file
@@ -0,0 +1 @@
|
||||
REDIS0006<EFBFBD>ܳC<EFBFBD>Z<EFBFBD><EFBFBD>V
|
21
vendor/maatwebsite/excel/phpunit.xml
vendored
Normal file
21
vendor/maatwebsite/excel/phpunit.xml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Package Test Suite">
|
||||
<directory suffix=".php">./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
|
||||
</php>
|
||||
</phpunit>
|
11
vendor/maatwebsite/excel/provides.json
vendored
Normal file
11
vendor/maatwebsite/excel/provides.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"providers": [
|
||||
"Maatwebsite\\Excel\\ExcelServiceProvider"
|
||||
],
|
||||
"aliases": [
|
||||
{
|
||||
"alias": "Excel",
|
||||
"facade": "Maatwebsite\\Excel\\Facades\\Excel"
|
||||
}
|
||||
]
|
||||
}
|
126
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/Cache.php
vendored
Normal file
126
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/Cache.php
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php namespace Maatwebsite\Excel\Classes;
|
||||
|
||||
use PHPExcel_Settings;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use PHPExcel_CachedObjectStorageFactory;
|
||||
|
||||
class Cache {
|
||||
|
||||
/**
|
||||
* PHPExcel cache class
|
||||
* @var string
|
||||
*/
|
||||
protected $class = 'PHPExcel_CachedObjectStorageFactory';
|
||||
|
||||
/**
|
||||
* Available caching drivers
|
||||
* @var array
|
||||
*/
|
||||
protected $available = array(
|
||||
'memory' => 'cache_in_memory',
|
||||
'gzip' => 'cache_in_memory_gzip',
|
||||
'serialized' => 'cache_in_memory_serialized',
|
||||
'igbinary' => 'cache_igbinary',
|
||||
'discISAM' => 'cache_to_discISAM',
|
||||
'apc' => 'cache_to_apc',
|
||||
'memcache' => 'cache_to_memcache',
|
||||
'temp' => 'cache_to_phpTemp',
|
||||
'wincache' => 'cache_to_wincache',
|
||||
'sqlite' => 'cache_to_sqlite',
|
||||
'sqlite3' => 'cache_to_sqlite3'
|
||||
);
|
||||
|
||||
/**
|
||||
* The name of the config file
|
||||
* @var string
|
||||
*/
|
||||
private $configName = 'excel.cache';
|
||||
|
||||
/**
|
||||
* Cache constructor
|
||||
*/
|
||||
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());
|
||||
|
||||
// Init if caching is enabled
|
||||
if ($this->isEnabled())
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the cache
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
// Find the cache driver
|
||||
$this->findDriver();
|
||||
|
||||
// Set the storage driver
|
||||
PHPExcel_Settings::setCacheStorageMethod($this->method, $this->settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the right driver
|
||||
* @return void
|
||||
*/
|
||||
public function findDriver()
|
||||
{
|
||||
$property = $this->detect();
|
||||
$this->method = constant($this->class . '::' . $property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect the caching driver
|
||||
* @return string $driver
|
||||
*/
|
||||
protected function detect()
|
||||
{
|
||||
// Add additional settings
|
||||
$this->addAdditionalSettings();
|
||||
|
||||
// return the driver
|
||||
return isset($this->available[$this->driver]) ? $this->available[$this->driver] : reset($this->available);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add additional settings for the current driver
|
||||
* @return void
|
||||
*/
|
||||
protected function addAdditionalSettings()
|
||||
{
|
||||
switch ($this->driver)
|
||||
{
|
||||
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)
|
||||
));
|
||||
|
||||
break;
|
||||
|
||||
case 'discISAM':
|
||||
|
||||
// Add dir
|
||||
$this->settings = array_merge($this->settings, array(
|
||||
'dir' => Config::get($this->configName . '.dir', storage_path('cache')),
|
||||
));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if caching is enabled
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
return Config::get($this->configName . '.enable', true) ? true : false;
|
||||
}
|
||||
}
|
274
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/FormatIdentifier.php
vendored
Normal file
274
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/FormatIdentifier.php
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
<?php namespace Maatwebsite\Excel\Classes;
|
||||
|
||||
use PHPExcel_IOFactory;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
|
||||
class FormatIdentifier {
|
||||
|
||||
/**
|
||||
* Available formats
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $formats = array(
|
||||
'Excel2007',
|
||||
'Excel5',
|
||||
'Excel2003XML',
|
||||
'OOCalc',
|
||||
'SYLK',
|
||||
'Gnumeric',
|
||||
'CSV',
|
||||
'HTML',
|
||||
'PDF'
|
||||
);
|
||||
|
||||
/**
|
||||
* Construct new format identifier
|
||||
* @param Filesystem $filesystem
|
||||
*/
|
||||
public function __construct(Filesystem $filesystem)
|
||||
{
|
||||
$this->filesystem = $filesystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file format by file
|
||||
* @param $file
|
||||
* @throws LaravelExcelException
|
||||
* @return string $format
|
||||
*/
|
||||
public function getFormatByFile($file)
|
||||
{
|
||||
// get the file extension
|
||||
$ext = $this->getExtension($file);
|
||||
|
||||
// get the file format
|
||||
$format = $this->getFormatByExtension($ext);
|
||||
|
||||
// Check if the file can be read
|
||||
if ($this->canRead($format, $file))
|
||||
return $format;
|
||||
|
||||
// Do a last try to init the file with all available readers
|
||||
return $this->lastResort($file, $format, $ext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify file format
|
||||
* @param $ext
|
||||
* @return string $format
|
||||
*/
|
||||
public function getFormatByExtension($ext)
|
||||
{
|
||||
switch ($ext)
|
||||
{
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Excel 2007
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'xlsx':
|
||||
case 'xlsm':
|
||||
case 'xltx':
|
||||
case 'xltm':
|
||||
return 'Excel2007';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Excel5
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'xls':
|
||||
case 'xlt':
|
||||
return 'Excel5';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| OOCalc
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'ods':
|
||||
case 'ots':
|
||||
return 'OOCalc';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SYLK
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'slk':
|
||||
return 'SYLK';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Excel2003XML
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'xml':
|
||||
return 'Excel2003XML';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Gnumeric
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'gnumeric':
|
||||
return 'Gnumeric';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTML
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'htm':
|
||||
case 'html':
|
||||
return 'HTML';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CSV
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'csv':
|
||||
case 'txt':
|
||||
return 'CSV';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PDF
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'pdf':
|
||||
return 'PDF';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content type by file format
|
||||
* @param string $format
|
||||
* @return string $contentType
|
||||
*/
|
||||
public function getContentTypeByFormat($format)
|
||||
{
|
||||
switch ($format)
|
||||
{
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Excel 2007
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'Excel2007':
|
||||
return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Excel5
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'Excel5':
|
||||
return 'application/vnd.ms-excel; charset=UTF-8';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTML
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'HTML':
|
||||
return 'HTML';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CSV
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'CSV':
|
||||
return 'application/csv; charset=UTF-8';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PDF
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'PDF':
|
||||
return'application/pdf; charset=UTF-8';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try every reader we have
|
||||
* @param $file
|
||||
* @param bool $wrongFormat
|
||||
* @param string $ext
|
||||
* @throws LaravelExcelException
|
||||
* @return string $format
|
||||
*/
|
||||
protected function lastResort($file, $wrongFormat = false, $ext = 'xls')
|
||||
{
|
||||
// Loop through all available formats
|
||||
foreach ($this->formats as $format)
|
||||
{
|
||||
// Check if the file could be read
|
||||
if ($wrongFormat != $format && $this->canRead($format, $file))
|
||||
return $format;
|
||||
}
|
||||
|
||||
// Give up searching and throw an exception
|
||||
throw new LaravelExcelException('[ERROR] Reader could not identify file format for file [' . $file . '] with extension [' . $ext . ']');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we can read the file
|
||||
* @param $format
|
||||
* @param $file
|
||||
* @return boolean
|
||||
*/
|
||||
protected function canRead($format, $file)
|
||||
{
|
||||
if ($format)
|
||||
{
|
||||
$reader = $this->initReader($format);
|
||||
|
||||
return $reader && $reader->canRead($file);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the reader based on the format
|
||||
* @param string $format
|
||||
* @return \PHPExcel_Reader_IReader
|
||||
*/
|
||||
protected function initReader($format)
|
||||
{
|
||||
return PHPExcel_IOFactory::createReader($format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file extension
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
protected function getExtension($file)
|
||||
{
|
||||
return strtolower($this->filesystem->extension($file));
|
||||
}
|
||||
}
|
1273
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/LaravelExcelWorksheet.php
vendored
Normal file
1273
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/LaravelExcelWorksheet.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
124
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/PHPExcel.php
vendored
Normal file
124
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/PHPExcel.php
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php namespace Maatwebsite\Excel\Classes;
|
||||
|
||||
use PHPExcel as PHPOffice_PHPExcel;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
/**
|
||||
*
|
||||
* Laravel wrapper for PHPExcel
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @copyright Original Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class PHPExcel extends PHPOffice_PHPExcel {
|
||||
|
||||
/**
|
||||
* Allowed autofill properties
|
||||
* @var array
|
||||
*/
|
||||
public $allowedProperties = array(
|
||||
'creator',
|
||||
'lastModifiedBy',
|
||||
'description',
|
||||
'subject',
|
||||
'keywords',
|
||||
'category',
|
||||
'manager',
|
||||
'company'
|
||||
);
|
||||
|
||||
/**
|
||||
* Create sheet and add it to this workbook
|
||||
*
|
||||
* @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last)
|
||||
* @param bool|string $title
|
||||
* @throws \PHPExcel_Exception
|
||||
* @return LaravelExcelWorksheet
|
||||
*/
|
||||
public function createSheet($iSheetIndex = null, $title = false)
|
||||
{
|
||||
// Init new Laravel Excel worksheet
|
||||
$newSheet = new LaravelExcelWorksheet($this, $title);
|
||||
|
||||
// Add the sheet
|
||||
$this->addSheet($newSheet, $iSheetIndex);
|
||||
|
||||
// Return the sheet
|
||||
return $newSheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user change change the workbook property
|
||||
* @param string $method
|
||||
* @return boolean
|
||||
*/
|
||||
public function isChangeableProperty($method)
|
||||
{
|
||||
$name = lcfirst(str_replace('set', '', $method));
|
||||
|
||||
return in_array($name, $this->getAllowedProperties()) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default properties
|
||||
* @param array $custom
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultProperties($custom = [])
|
||||
{
|
||||
// Get the properties
|
||||
$properties = $this->getProperties();
|
||||
|
||||
// Get fillable properties
|
||||
foreach ($this->getAllowedProperties() as $prop)
|
||||
{
|
||||
// Get the method
|
||||
$method = 'set' . ucfirst($prop);
|
||||
|
||||
// get the value
|
||||
$value = in_array($prop, array_keys($custom)) ? $custom[$prop] : Config::get('excel.properties.' . $prop, null);
|
||||
|
||||
// set the property
|
||||
call_user_func_array(array($properties, $method), array($value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* load info from parent obj
|
||||
* @param \PHPExcel $object
|
||||
* @return $this
|
||||
*/
|
||||
function cloneParent(\PHPExcel $object)
|
||||
{
|
||||
// Init new reflection object
|
||||
$class = new \ReflectionClass(get_class($object));
|
||||
|
||||
// Loop through all properties
|
||||
foreach($class->getProperties() as $property)
|
||||
{
|
||||
// Make the property public
|
||||
$property->setAccessible(true);
|
||||
|
||||
// Set the found value to this sheet
|
||||
$property->setValue(
|
||||
$this,
|
||||
$property->getValue($object)
|
||||
);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all allowed properties
|
||||
* @return array
|
||||
*/
|
||||
public function getAllowedProperties()
|
||||
{
|
||||
return $this->allowedProperties;
|
||||
}
|
||||
}
|
68
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/CellCollection.php
vendored
Normal file
68
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/CellCollection.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php namespace Maatwebsite\Excel\Collections;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel CellCollection
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class CellCollection extends ExcelCollection {
|
||||
|
||||
/**
|
||||
* Create a new collection.
|
||||
* @param array $items
|
||||
* @return \Maatwebsite\Excel\Collections\CellCollection
|
||||
*/
|
||||
public function __construct(array $items = array())
|
||||
{
|
||||
$this->setItems($items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the items
|
||||
* @param array $items
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically get values
|
||||
* @param string $key
|
||||
* @return string
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
if ($this->has($key))
|
||||
return $this->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an attribute exists on the model.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
return $this->has($key);
|
||||
}
|
||||
}
|
41
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/ExcelCollection.php
vendored
Normal file
41
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/ExcelCollection.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php namespace Maatwebsite\Excel\Collections;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel ExcelCollection
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class ExcelCollection extends Collection {
|
||||
|
||||
/**
|
||||
* Sheet title
|
||||
* @var [type]
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* Get the title
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title
|
||||
* @param $title
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
}
|
16
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/RowCollection.php
vendored
Normal file
16
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/RowCollection.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php namespace Maatwebsite\Excel\Collections;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel RowCollection
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class RowCollection extends ExcelCollection {
|
||||
|
||||
}
|
16
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/SheetCollection.php
vendored
Normal file
16
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/SheetCollection.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php namespace Maatwebsite\Excel\Collections;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel SheetCollection
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class SheetCollection extends ExcelCollection {
|
||||
|
||||
}
|
278
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Excel.php
vendored
Normal file
278
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Excel.php
vendored
Normal file
@@ -0,0 +1,278 @@
|
||||
<?php namespace Maatwebsite\Excel;
|
||||
|
||||
use Closure;
|
||||
use Maatwebsite\Excel\Readers\Batch;
|
||||
use Maatwebsite\Excel\Classes\PHPExcel;
|
||||
use Maatwebsite\Excel\Readers\LaravelExcelReader;
|
||||
use Maatwebsite\Excel\Writers\LaravelExcelWriter;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Laravel wrapper for PHPExcel
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class Excel {
|
||||
|
||||
/**
|
||||
* Filter
|
||||
* @var array
|
||||
*/
|
||||
protected $filters = array(
|
||||
'registered' => array(),
|
||||
'enabled' => array()
|
||||
);
|
||||
|
||||
/**
|
||||
* Excel object
|
||||
* @var PHPExcel
|
||||
*/
|
||||
protected $excel;
|
||||
|
||||
/**
|
||||
* Reader object
|
||||
* @var LaravelExcelReader
|
||||
*/
|
||||
protected $reader;
|
||||
|
||||
/**
|
||||
* Writer object
|
||||
* @var LaravelExcelWriter
|
||||
*/
|
||||
protected $writer;
|
||||
|
||||
/**
|
||||
* Construct Excel
|
||||
* @param PHPExcel $excel
|
||||
* @param LaravelExcelReader $reader
|
||||
* @param LaravelExcelWriter $writer
|
||||
*/
|
||||
public function __construct(PHPExcel $excel, LaravelExcelReader $reader, LaravelExcelWriter $writer)
|
||||
{
|
||||
// Set Excel dependencies
|
||||
$this->excel = $excel;
|
||||
$this->reader = $reader;
|
||||
$this->writer = $writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new file
|
||||
* @param $filename
|
||||
* @param callable|null $callback
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function create($filename, $callback = null)
|
||||
{
|
||||
// Writer instance
|
||||
$writer = clone $this->writer;
|
||||
|
||||
// Disconnect worksheets to prevent unnecessary ones
|
||||
$this->excel->disconnectWorksheets();
|
||||
|
||||
// Inject our excel object
|
||||
$writer->injectExcel($this->excel);
|
||||
|
||||
// Set the filename and title
|
||||
$writer->setFileName($filename);
|
||||
$writer->setTitle($filename);
|
||||
|
||||
// Do the callback
|
||||
if ($callback instanceof Closure)
|
||||
call_user_func($callback, $writer);
|
||||
|
||||
// Return the writer object
|
||||
return $writer;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Load an existing file
|
||||
*
|
||||
* @param string $file The file we want to load
|
||||
* @param callback|null $callback
|
||||
* @param string|null $encoding
|
||||
* @param bool $noBasePath
|
||||
* @return LaravelExcelReader
|
||||
*/
|
||||
public function load($file, $callback = null, $encoding = null, $noBasePath = false, $callbackConfigReader = null)
|
||||
{
|
||||
// Reader instance
|
||||
$reader = clone $this->reader;
|
||||
|
||||
// Inject excel object
|
||||
$reader->injectExcel($this->excel);
|
||||
|
||||
// Enable filters
|
||||
$reader->setFilters($this->filters);
|
||||
|
||||
// Set the encoding
|
||||
$encoding = is_string($callback) ? $callback : $encoding;
|
||||
|
||||
// Start loading
|
||||
$reader->load($file, $encoding, $noBasePath, $callbackConfigReader);
|
||||
|
||||
// Do the callback
|
||||
if ($callback instanceof Closure)
|
||||
call_user_func($callback, $reader);
|
||||
|
||||
// Return the reader object
|
||||
return $reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set select sheets
|
||||
* @param $sheets
|
||||
* @return LaravelExcelReader
|
||||
*/
|
||||
public function selectSheets($sheets = array())
|
||||
{
|
||||
$sheets = is_array($sheets) ? $sheets : func_get_args();
|
||||
$this->reader->setSelectedSheets($sheets);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select sheets by index
|
||||
* @param array $sheets
|
||||
* @return $this
|
||||
*/
|
||||
public function selectSheetsByIndex($sheets = array())
|
||||
{
|
||||
$sheets = is_array($sheets) ? $sheets : func_get_args();
|
||||
$this->reader->setSelectedSheetIndices($sheets);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch import
|
||||
* @param $files
|
||||
* @param callback $callback
|
||||
* @return PHPExcel
|
||||
*/
|
||||
public function batch($files, Closure $callback)
|
||||
{
|
||||
$batch = new Batch;
|
||||
|
||||
return $batch->start($this, $files, $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new file and share a view
|
||||
* @param string $view
|
||||
* @param array $data
|
||||
* @param array $mergeData
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function shareView($view, $data = array(), $mergeData = array())
|
||||
{
|
||||
return $this->create($view)->shareView($view, $data, $mergeData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new file and load a view
|
||||
* @param string $view
|
||||
* @param array $data
|
||||
* @param array $mergeData
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function loadView($view, $data = array(), $mergeData = array())
|
||||
{
|
||||
return $this->shareView($view, $data, $mergeData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set filters
|
||||
* @param array $filters
|
||||
* @return Excel
|
||||
*/
|
||||
public function registerFilters($filters = array())
|
||||
{
|
||||
// If enabled array key exists
|
||||
if(array_key_exists('enabled', $filters))
|
||||
{
|
||||
// Set registered array
|
||||
$registered = $filters['registered'];
|
||||
|
||||
// Filter on enabled
|
||||
$this->filter($filters['enabled']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$registered = $filters;
|
||||
}
|
||||
|
||||
// Register the filters
|
||||
$this->filters['registered'] = !empty($this->filters['registered']) ? array_merge($this->filters['registered'], $registered) : $registered;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable certain filters
|
||||
* @param string|array $filter
|
||||
* @param bool|false|string $class
|
||||
* @return Excel
|
||||
*/
|
||||
public function filter($filter, $class = false)
|
||||
{
|
||||
// Add multiple filters
|
||||
if(is_array($filter))
|
||||
{
|
||||
$this->filters['enabled'] = !empty($this->filters['enabled']) ? array_merge($this->filters['enabled'], $filter) : $filter;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add single filter
|
||||
$this->filters['enabled'][] = $filter;
|
||||
|
||||
// Overrule filter class for this request
|
||||
if($class)
|
||||
$this->filters['registered'][$filter] = $class;
|
||||
}
|
||||
|
||||
// Remove duplicates
|
||||
$this->filters['enabled'] = array_unique($this->filters['enabled']);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get register, enabled (or both) filters
|
||||
* @param string|boolean $key [description]
|
||||
* @return array
|
||||
*/
|
||||
public function getFilters($key = false)
|
||||
{
|
||||
return $key ? $this->filters[$key] : $this->filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call methods
|
||||
* @throws LaravelExcelException
|
||||
*/
|
||||
public function __call($method, $params)
|
||||
{
|
||||
// If the dynamic call starts with "with", add the var to the data array
|
||||
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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
throw new LaravelExcelException('Laravel Excel method [' . $method . '] does not exist');
|
||||
}
|
||||
}
|
247
vendor/maatwebsite/excel/src/Maatwebsite/Excel/ExcelServiceProvider.php
vendored
Normal file
247
vendor/maatwebsite/excel/src/Maatwebsite/Excel/ExcelServiceProvider.php
vendored
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php namespace Maatwebsite\Excel;
|
||||
|
||||
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\Facades\Response;
|
||||
use Maatwebsite\Excel\Parsers\CssParser;
|
||||
use Maatwebsite\Excel\Parsers\ViewParser;
|
||||
use Maatwebsite\Excel\Classes\FormatIdentifier;
|
||||
use Maatwebsite\Excel\Readers\LaravelExcelReader;
|
||||
use Maatwebsite\Excel\Writers\LaravelExcelWriter;
|
||||
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel Excel ServiceProvider
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class ExcelServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = false;
|
||||
|
||||
/**
|
||||
* Bootstrap the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function boot()
|
||||
{
|
||||
$this->publishes([
|
||||
__DIR__ . '/../../config/excel.php' => config_path('excel.php'),
|
||||
]);
|
||||
|
||||
$this->mergeConfigFrom(
|
||||
__DIR__ . '/../../config/excel.php', 'excel'
|
||||
);
|
||||
|
||||
//Set the autosizing settings
|
||||
$this->setAutoSizingSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->bindClasses();
|
||||
$this->bindCssParser();
|
||||
$this->bindReaders();
|
||||
$this->bindParsers();
|
||||
$this->bindPHPExcelClass();
|
||||
$this->bindWriters();
|
||||
$this->bindExcel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind PHPExcel classes
|
||||
* @return void
|
||||
*/
|
||||
protected function bindPHPExcelClass()
|
||||
{
|
||||
// Set object
|
||||
$me = $this;
|
||||
|
||||
// Bind the PHPExcel class
|
||||
$this->app['phpexcel'] = $this->app->share(function () use ($me)
|
||||
{
|
||||
// Set locale
|
||||
$me->setLocale();
|
||||
|
||||
// Set the caching settings
|
||||
$me->setCacheSettings();
|
||||
|
||||
// Init phpExcel
|
||||
$excel = new PHPExcel();
|
||||
$excel->setDefaultProperties();
|
||||
return $excel;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind the css parser
|
||||
*/
|
||||
protected function bindCssParser()
|
||||
{
|
||||
// Bind css parser
|
||||
$this->app['excel.parsers.css'] = $this->app->share(function ()
|
||||
{
|
||||
return new CssParser(
|
||||
new CssToInlineStyles()
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind writers
|
||||
* @return void
|
||||
*/
|
||||
protected function bindReaders()
|
||||
{
|
||||
// Bind the laravel excel reader
|
||||
$this->app['excel.reader'] = $this->app->share(function ($app)
|
||||
{
|
||||
return new LaravelExcelReader(
|
||||
$app['files'],
|
||||
$app['excel.identifier'],
|
||||
$app['Illuminate\Contracts\Bus\Dispatcher']
|
||||
);
|
||||
});
|
||||
|
||||
// Bind the html reader class
|
||||
$this->app['excel.readers.html'] = $this->app->share(function ($app)
|
||||
{
|
||||
return new Html(
|
||||
$app['excel.parsers.css']
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind writers
|
||||
* @return void
|
||||
*/
|
||||
protected function bindParsers()
|
||||
{
|
||||
// Bind the view parser
|
||||
$this->app['excel.parsers.view'] = $this->app->share(function ($app)
|
||||
{
|
||||
return new ViewParser(
|
||||
$app['excel.readers.html']
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind writers
|
||||
* @return void
|
||||
*/
|
||||
protected function bindWriters()
|
||||
{
|
||||
// Bind the excel writer
|
||||
$this->app['excel.writer'] = $this->app->share(function ($app)
|
||||
{
|
||||
return new LaravelExcelWriter(
|
||||
$app->make(Response::class),
|
||||
$app['files'],
|
||||
$app['excel.identifier']
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind Excel class
|
||||
* @return void
|
||||
*/
|
||||
protected function bindExcel()
|
||||
{
|
||||
// Bind the Excel class and inject its dependencies
|
||||
$this->app['excel'] = $this->app->share(function ($app)
|
||||
{
|
||||
$excel = new Excel(
|
||||
$app['phpexcel'],
|
||||
$app['excel.reader'],
|
||||
$app['excel.writer'],
|
||||
$app['excel.parsers.view']
|
||||
);
|
||||
|
||||
$excel->registerFilters($app['config']->get('excel.filters', array()));
|
||||
|
||||
return $excel;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind other classes
|
||||
* @return void
|
||||
*/
|
||||
protected function bindClasses()
|
||||
{
|
||||
// Bind the format identifier
|
||||
$this->app['excel.identifier'] = $this->app->share(function ($app)
|
||||
{
|
||||
return new FormatIdentifier($app['files']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cache settings
|
||||
* @return Cache
|
||||
*/
|
||||
public function setCacheSettings()
|
||||
{
|
||||
return new Cache();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set locale
|
||||
*/
|
||||
public function setLocale()
|
||||
{
|
||||
$locale = Config::get('app.locale', 'en_us');
|
||||
PHPExcel_Settings::setLocale($locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the autosizing settings
|
||||
*/
|
||||
public function setAutoSizingSettings()
|
||||
{
|
||||
$method = Config::get('excel.export.autosize-method', PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX);
|
||||
PHPExcel_Shared_Font::setAutoSizeMethod($method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return array(
|
||||
'excel',
|
||||
'phpexcel',
|
||||
'excel.reader',
|
||||
'excel.readers.html',
|
||||
'excel.parsers.view',
|
||||
'excel.writer'
|
||||
);
|
||||
}
|
||||
}
|
18
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Exceptions/LaravelExcelException.php
vendored
Normal file
18
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Exceptions/LaravelExcelException.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php namespace Maatwebsite\Excel\Exceptions;
|
||||
|
||||
use PHPExcel_Exception;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel Exception
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class LaravelExcelException extends PHPExcel_Exception {
|
||||
|
||||
}
|
26
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Facades/Excel.php
vendored
Normal file
26
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Facades/Excel.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php namespace Maatwebsite\Excel\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel Facade
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class Excel extends Facade {
|
||||
|
||||
/**
|
||||
* Return facade accessor
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'excel';
|
||||
}
|
||||
}
|
156
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/ExcelFile.php
vendored
Normal file
156
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/ExcelFile.php
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php namespace Maatwebsite\Excel\Files;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
|
||||
abstract class ExcelFile extends File {
|
||||
|
||||
/**
|
||||
* @var bool|string
|
||||
*/
|
||||
protected $delimiter;
|
||||
|
||||
/**
|
||||
* @var bool|string
|
||||
*/
|
||||
protected $enclosure;
|
||||
|
||||
/**
|
||||
* @var null
|
||||
*/
|
||||
protected $encoding = null;
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
* @param Excel $excel
|
||||
*/
|
||||
public function __construct(Application $app, Excel $excel)
|
||||
{
|
||||
parent::__construct($app, $excel);
|
||||
$this->file = $this->loadFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getFile();
|
||||
|
||||
/**
|
||||
* Get delimiter
|
||||
* @return string
|
||||
*/
|
||||
protected function getDelimiter()
|
||||
{
|
||||
return $this->delimiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enclosure
|
||||
* @return string
|
||||
*/
|
||||
protected function getEnclosure()
|
||||
{
|
||||
return $this->enclosure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filters
|
||||
* @return array
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Start importing
|
||||
*/
|
||||
public function handleImport()
|
||||
{
|
||||
return $this->handle(
|
||||
get_class($this)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the file
|
||||
* @return \Maatwebsite\Excel\Readers\LaravelExcelReader
|
||||
*/
|
||||
public function loadFile()
|
||||
{
|
||||
// Load filters
|
||||
$this->loadFilters();
|
||||
|
||||
// Load base settings
|
||||
$this->loadBaseSettings();
|
||||
|
||||
// Load the file
|
||||
$file = $this->excel->load(
|
||||
$this->getFile(),
|
||||
null,
|
||||
$this->encoding
|
||||
);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the filter
|
||||
* @return void
|
||||
*/
|
||||
protected function loadFilters()
|
||||
{
|
||||
// Register the filters
|
||||
$this->excel->registerFilters(
|
||||
$this->getFilters()
|
||||
);
|
||||
|
||||
// Loop through the filters
|
||||
foreach($this->getFilters() as $filter)
|
||||
{
|
||||
// Enable the filter
|
||||
$this->excel->filter($filter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load base settings
|
||||
*/
|
||||
protected function loadBaseSettings()
|
||||
{
|
||||
$this->loadCSVSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load CSV Settings
|
||||
*/
|
||||
protected function loadCSVSettings()
|
||||
{
|
||||
// Get user provided delimiter
|
||||
$delimiter = $this->getDelimiter();
|
||||
|
||||
// Set it when given
|
||||
if($delimiter)
|
||||
$this->excel->setDelimiter($delimiter);
|
||||
|
||||
// Get user provided enclosure
|
||||
$enclosure = $this->getEnclosure();
|
||||
|
||||
// Set it when given
|
||||
if($enclosure)
|
||||
$this->excel->setEnclosure($enclosure);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call methods
|
||||
* @param string $method
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $params)
|
||||
{
|
||||
return call_user_func_array([$this->file, $method], $params);
|
||||
}
|
||||
}
|
12
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/ExportHandler.php
vendored
Normal file
12
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/ExportHandler.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php namespace Maatwebsite\Excel\Files;
|
||||
|
||||
interface ExportHandler {
|
||||
|
||||
/**
|
||||
* Handle the export
|
||||
* @param $file
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($file);
|
||||
|
||||
}
|
90
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/File.php
vendored
Normal file
90
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/File.php
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php namespace Maatwebsite\Excel\Files;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
|
||||
abstract class File {
|
||||
|
||||
/**
|
||||
* @var Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* Excel instance
|
||||
* @var Excel
|
||||
*/
|
||||
protected $excel;
|
||||
|
||||
/**
|
||||
* Loaded file
|
||||
* @var \Maatwebsite\Excel\Readers\LaravelExcelReader
|
||||
*/
|
||||
protected $file;
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
* @param Excel $excel
|
||||
*/
|
||||
public function __construct(Application $app, Excel $excel)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->excel = $excel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the import/export of the file
|
||||
* @param $type
|
||||
* @throws LaravelExcelException
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($type)
|
||||
{
|
||||
// Get the handler
|
||||
$handler = $this->getHandler($type);
|
||||
|
||||
// Call the handle method and inject the file
|
||||
return $handler->handle($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get handler
|
||||
* @param $type
|
||||
* @throws LaravelExcelException
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getHandler($type)
|
||||
{
|
||||
return $this->app->make(
|
||||
$this->getHandlerClassName($type)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file instance
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFileInstance()
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the handler class name
|
||||
* @throws LaravelExcelException
|
||||
* @return string
|
||||
*/
|
||||
protected function getHandlerClassName($type)
|
||||
{
|
||||
// Translate the file into a FileHandler
|
||||
$class = get_class($this);
|
||||
$handler = substr_replace($class, $type . 'Handler', strrpos($class, $type));
|
||||
|
||||
// Check if the handler exists
|
||||
if (!class_exists($handler))
|
||||
throw new LaravelExcelException("$type handler [$handler] does not exist.");
|
||||
|
||||
return $handler;
|
||||
}
|
||||
}
|
12
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/ImportHandler.php
vendored
Normal file
12
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/ImportHandler.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php namespace Maatwebsite\Excel\Files;
|
||||
|
||||
interface ImportHandler {
|
||||
|
||||
/**
|
||||
* Handle the import
|
||||
* @param $file
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($file);
|
||||
|
||||
}
|
60
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/NewExcelFile.php
vendored
Normal file
60
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/NewExcelFile.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php namespace Maatwebsite\Excel\Files;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
|
||||
abstract class NewExcelFile extends File {
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
* @param Excel $excel
|
||||
*/
|
||||
public function __construct(Application $app, Excel $excel)
|
||||
{
|
||||
parent::__construct($app, $excel);
|
||||
$this->file = $this->createNewFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getFilename();
|
||||
|
||||
/**
|
||||
* Start importing
|
||||
*/
|
||||
public function handleExport()
|
||||
{
|
||||
return $this->handle(
|
||||
get_class($this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load the file
|
||||
* @return \Maatwebsite\Excel\Readers\LaravelExcelReader
|
||||
*/
|
||||
public function createNewFile()
|
||||
{
|
||||
// Load the file
|
||||
$file = $this->excel->create(
|
||||
$this->getFilename()
|
||||
);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call methods
|
||||
* @param string $method
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $params)
|
||||
{
|
||||
return call_user_func_array([$this->file, $method], $params);
|
||||
}
|
||||
|
||||
}
|
46
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Filters/ChunkReadFilter.php
vendored
Normal file
46
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Filters/ChunkReadFilter.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php namespace Maatwebsite\Excel\Filters;
|
||||
|
||||
use PHPExcel_Reader_IReadFilter;
|
||||
|
||||
class ChunkReadFilter implements PHPExcel_Reader_IReadFilter
|
||||
{
|
||||
/**
|
||||
* Start row
|
||||
* @var integer
|
||||
*/
|
||||
private $_startRow = 0;
|
||||
|
||||
/**
|
||||
* End row
|
||||
* @var integer
|
||||
*/
|
||||
private $_endRow = 0;
|
||||
|
||||
/**
|
||||
* Set the list of rows that we want to read
|
||||
* @param integer $startRow
|
||||
* @param integer $chunkSize
|
||||
* @return void
|
||||
*/
|
||||
public function setRows($startRow, $chunkSize)
|
||||
{
|
||||
$this->_startRow = $startRow;
|
||||
$this->_endRow = $startRow + $chunkSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the cell
|
||||
* @param string $column
|
||||
* @param integer $row
|
||||
* @param string $worksheetName
|
||||
* @return booleaan
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
134
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/CssParser.php
vendored
Normal file
134
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/CssParser.php
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php namespace Maatwebsite\Excel\Parsers;
|
||||
|
||||
use DOMDocument;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel CSS Parser
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class CssParser {
|
||||
|
||||
/**
|
||||
* @var CssToInlineStyles
|
||||
*/
|
||||
protected $cssInliner;
|
||||
|
||||
/**
|
||||
* DOM xml
|
||||
* @var \SimpleXMLElement
|
||||
*/
|
||||
protected $xml;
|
||||
|
||||
/**
|
||||
* Style sheet links
|
||||
* @var array
|
||||
*/
|
||||
protected $links = array();
|
||||
|
||||
/**
|
||||
* Construct the css parser
|
||||
* @param CssToInlineStyles $cssInliner
|
||||
*/
|
||||
public function __construct(CssToInlineStyles $cssInliner)
|
||||
{
|
||||
$this->cssInliner = $cssInliner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the found css to inline styles
|
||||
*/
|
||||
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);
|
||||
|
||||
// Loop through all stylesheets
|
||||
foreach($this->links as $link)
|
||||
{
|
||||
$css = file_get_contents($link);
|
||||
$this->cssInliner->setCSS($css);
|
||||
}
|
||||
|
||||
return $this->cssInliner->convert();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the stylesheets inside the view
|
||||
* @param DOMDocument $dom
|
||||
* @return CssParser
|
||||
*/
|
||||
public function findStyleSheets(DOMDocument $dom)
|
||||
{
|
||||
// Import the dom
|
||||
$this->importDom($dom);
|
||||
|
||||
// Get all stylesheet tags
|
||||
$tags = $this->getStyleSheetTags();
|
||||
|
||||
foreach ($tags as $node)
|
||||
{
|
||||
$this->links[] = $this->getCleanStyleSheetLink($node);
|
||||
}
|
||||
|
||||
// We don't need duplicate css files
|
||||
$this->links = array_unique($this->links);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import the dom
|
||||
* @return SimpleXMLElement
|
||||
*/
|
||||
protected function importDom(DOMDocument $dom)
|
||||
{
|
||||
return $this->xml = simplexml_import_dom($dom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all stylesheet tags
|
||||
* @return array
|
||||
*/
|
||||
protected function getStyleSheetTags()
|
||||
{
|
||||
return $this->xml->xpath('//link[@rel="stylesheet"]');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the clean link to the stylesheet
|
||||
* @param string $node
|
||||
* @return string
|
||||
*/
|
||||
protected function getCleanStyleSheetLink($node)
|
||||
{
|
||||
// Get the link
|
||||
$link = $node->attributes()->href;
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get css from link
|
||||
* @param string $link
|
||||
* @return string|boolean
|
||||
*/
|
||||
protected function getCssFromLink($link)
|
||||
{
|
||||
return file_get_contents($link);
|
||||
}
|
||||
}
|
667
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/ExcelParser.php
vendored
Normal file
667
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/ExcelParser.php
vendored
Normal file
@@ -0,0 +1,667 @@
|
||||
<?php namespace Maatwebsite\Excel\Parsers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
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;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel Excel Parser
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class ExcelParser {
|
||||
|
||||
/**
|
||||
* If file is parsed
|
||||
* @var boolean
|
||||
*/
|
||||
public $isParsed = false;
|
||||
|
||||
/**
|
||||
* Reader object
|
||||
* @var LaravelExcelReader
|
||||
*/
|
||||
protected $reader;
|
||||
|
||||
/**
|
||||
* Excel object
|
||||
* @var PHPExcel
|
||||
*/
|
||||
protected $excel;
|
||||
|
||||
/**
|
||||
* Worksheet object
|
||||
* @var LaravelExcelWorksheet
|
||||
*/
|
||||
protected $worksheet;
|
||||
|
||||
/**
|
||||
* Row object
|
||||
* @var PHPExcel_Worksheet_Row
|
||||
*/
|
||||
protected $row;
|
||||
|
||||
/**
|
||||
* Cell object
|
||||
* @var PHPExcel_Cell
|
||||
*/
|
||||
protected $cell;
|
||||
|
||||
/**
|
||||
* Indices
|
||||
* @var array
|
||||
*/
|
||||
protected $indices;
|
||||
|
||||
/**
|
||||
* Columns we want to fetch
|
||||
* @var array
|
||||
*/
|
||||
protected $columns = array();
|
||||
|
||||
/**
|
||||
* Row counter
|
||||
* @var integer
|
||||
*/
|
||||
protected $currentRow = 1;
|
||||
|
||||
/**
|
||||
* Default startrow
|
||||
* @var integer
|
||||
*/
|
||||
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);
|
||||
|
||||
// Reset
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the file
|
||||
* @param array $columns
|
||||
* @return SheetCollection
|
||||
*/
|
||||
public function parseFile($columns = array())
|
||||
{
|
||||
// Init new sheet collection
|
||||
$workbook = new SheetCollection();
|
||||
|
||||
// Set the selected columns
|
||||
$this->setSelectedColumns($columns);
|
||||
|
||||
// If not parsed yet
|
||||
if ( !$this->isParsed )
|
||||
{
|
||||
// Set worksheet count
|
||||
$this->w = 0;
|
||||
|
||||
// Get selected sheets
|
||||
$iterator = $this->excel->getWorksheetIterator();
|
||||
|
||||
// Loop through the worksheets
|
||||
foreach ($iterator as $this->worksheet)
|
||||
{
|
||||
// Check if the sheet might have been selected by it's index
|
||||
if ( $this->reader->isSelectedByIndex($iterator->key()) )
|
||||
{
|
||||
// Parse the worksheet
|
||||
$worksheet = $this->parseWorksheet();
|
||||
|
||||
// If multiple sheets
|
||||
if ( $this->parseAsMultiple() )
|
||||
{
|
||||
// Push every sheet
|
||||
$workbook->push($worksheet);
|
||||
$workbook->setTitle($this->excel->getProperties()->getTitle());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignore the sheet collection
|
||||
$workbook = $worksheet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->w++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->isParsed = true;
|
||||
|
||||
// Return itself
|
||||
return $workbook;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we want to parse it as multiple sheets
|
||||
* @return boolean
|
||||
*/
|
||||
protected function parseAsMultiple()
|
||||
{
|
||||
return ($this->excel->getSheetCount() > 1 && count($this->reader->getSelectedSheetIndices()) !== 1)
|
||||
|| Config::get('excel.import.force_sheets_collection', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the worksheet
|
||||
* @return RowCollection
|
||||
*/
|
||||
protected function parseWorksheet()
|
||||
{
|
||||
// Set the active worksheet
|
||||
$this->excel->setActiveSheetIndex($this->w);
|
||||
|
||||
// Fetch the labels
|
||||
$this->indices = $this->reader->hasHeading() ? $this->getIndices() : array();
|
||||
|
||||
// Parse the rows
|
||||
return $this->parseRows();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the indices
|
||||
* @return array
|
||||
*/
|
||||
protected function getIndices()
|
||||
{
|
||||
// Fetch the first row
|
||||
$this->row = $this->worksheet->getRowIterator($this->defaultStartRow)->current();
|
||||
|
||||
// Set empty labels array
|
||||
$this->indices = array();
|
||||
|
||||
// Loop through the cells
|
||||
foreach ($this->row->getCellIterator() as $this->cell)
|
||||
{
|
||||
$this->indices[] = $this->getIndex($this->cell);
|
||||
}
|
||||
|
||||
// Return the labels
|
||||
return $this->indices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index
|
||||
* @param $cell
|
||||
* @return string
|
||||
*/
|
||||
protected function getIndex($cell)
|
||||
{
|
||||
// Get heading type
|
||||
$config = Config::get('excel.import.heading', true);
|
||||
$config = $config === true ? 'slugged' : $config;
|
||||
|
||||
// Get value
|
||||
$value = $this->getOriginalIndex($cell);
|
||||
|
||||
switch ($config)
|
||||
{
|
||||
case 'slugged':
|
||||
return $this->getSluggedIndex($value, Config::get('excel.import.to_ascii', true));
|
||||
break;
|
||||
case 'slugged_with_count':
|
||||
$index = $this->getSluggedIndex($value, Config::get('excel.import.to_ascii', true));
|
||||
if(in_array($index,$this->indices)){
|
||||
$index = $this->appendOrIncreaseStringCount($index);
|
||||
}
|
||||
return $index;
|
||||
break;
|
||||
|
||||
case 'ascii':
|
||||
return $this->getAsciiIndex($value);
|
||||
break;
|
||||
|
||||
case 'hashed':
|
||||
return $this->getHashedIndex($value);
|
||||
break;
|
||||
|
||||
case 'trans':
|
||||
return $this->getTranslatedIndex($value);
|
||||
break;
|
||||
|
||||
case 'original':
|
||||
return $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Append or increase the count at the String like: test to test_1
|
||||
* @param string $index
|
||||
* @return string
|
||||
*/
|
||||
protected function appendOrIncreaseStringCount($index)
|
||||
{
|
||||
do {
|
||||
if (preg_match("/(\d+)$/",$index,$matches) === 1)
|
||||
{
|
||||
// increase +1
|
||||
$index = preg_replace_callback( "/(\d+)$/",
|
||||
function ($matches) {
|
||||
return ++$matches[1];
|
||||
}, $index);
|
||||
}
|
||||
else
|
||||
{
|
||||
$index .= '_1';
|
||||
}
|
||||
|
||||
} while(in_array($index,$this->indices));
|
||||
|
||||
return $index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slugged index
|
||||
* @param string $value
|
||||
* @param bool $ascii
|
||||
* @return string
|
||||
*/
|
||||
protected function getSluggedIndex($value, $ascii = false)
|
||||
{
|
||||
// Get original
|
||||
$separator = $this->reader->getSeparator();
|
||||
|
||||
// Convert to ascii when needed
|
||||
if ( $ascii )
|
||||
$value = $this->getAsciiIndex($value);
|
||||
|
||||
// Convert all dashes/underscores into separator
|
||||
$flip = $separator == '-' ? '_' : '-';
|
||||
$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));
|
||||
|
||||
// Replace all separator characters and whitespace by a single separator
|
||||
$value = preg_replace('![' . preg_quote($separator) . '\s]+!u', $separator, $value);
|
||||
|
||||
return trim($value, $separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ASCII index
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
protected function getAsciiIndex($value)
|
||||
{
|
||||
return Str::ascii($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hahsed index
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
protected function getHashedIndex($value)
|
||||
{
|
||||
return md5($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get translated index
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
protected function getTranslatedIndex($value)
|
||||
{
|
||||
return trans($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get orignal indice
|
||||
* @param $cell
|
||||
* @return string
|
||||
*/
|
||||
protected function getOriginalIndex($cell)
|
||||
{
|
||||
return $cell->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the rows
|
||||
* @return RowCollection
|
||||
*/
|
||||
protected function parseRows()
|
||||
{
|
||||
// Set empty parsedRow array
|
||||
$parsedRows = new RowCollection();
|
||||
|
||||
// set sheet title
|
||||
$parsedRows->setTitle($this->excel->getActiveSheet()->getTitle());
|
||||
|
||||
// Get the start row
|
||||
$startRow = $this->getStartRow();
|
||||
|
||||
try {
|
||||
$rows = $this->worksheet->getRowIterator($startRow);
|
||||
} catch(PHPExcel_Exception $e) {
|
||||
$rows = [];
|
||||
}
|
||||
|
||||
// Loop through the rows inside the worksheet
|
||||
foreach ($rows as $this->row)
|
||||
{
|
||||
// Limit the results when needed
|
||||
if ( $this->hasReachedLimit() )
|
||||
break;
|
||||
|
||||
// Push the parsed cells inside the parsed rows
|
||||
$parsedRows->push($this->parseCells());
|
||||
|
||||
// Count the rows
|
||||
$this->currentRow++;
|
||||
}
|
||||
|
||||
// Return the parsed array
|
||||
return $parsedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the startrow
|
||||
* @return integer
|
||||
*/
|
||||
protected function getStartRow()
|
||||
{
|
||||
// Set default start row
|
||||
$startRow = $this->defaultStartRow;
|
||||
|
||||
// If the reader has a heading, skip the first row
|
||||
if ( $this->reader->hasHeading() )
|
||||
$startRow++;
|
||||
|
||||
// Get the amount of rows to skip
|
||||
$skip = $this->reader->getSkip();
|
||||
|
||||
// If we want to skip rows, add the amount of rows
|
||||
if ( $skip > 0 )
|
||||
$startRow = $startRow + $skip;
|
||||
|
||||
// Return the startrow
|
||||
return $startRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for the limit
|
||||
* @return boolean
|
||||
*/
|
||||
protected function hasReachedLimit()
|
||||
{
|
||||
// Get skip
|
||||
$limit = $this->reader->getLimit();
|
||||
|
||||
// If we have a limit, check if we hit this limit
|
||||
return $limit && $this->currentRow > $limit ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the cells of the given row
|
||||
* @return CellCollection
|
||||
*/
|
||||
protected function parseCells()
|
||||
{
|
||||
$i = 0;
|
||||
$parsedCells = array();
|
||||
|
||||
try {
|
||||
// Set the cell iterator
|
||||
$cellIterator = $this->row->getCellIterator();
|
||||
|
||||
// Ignore empty cells if needed
|
||||
$cellIterator->setIterateOnlyExistingCells($this->reader->needsIgnoreEmpty());
|
||||
|
||||
// Foreach cells
|
||||
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();
|
||||
|
||||
// Check if we want to select this column
|
||||
if ( $this->cellNeedsParsing($index) )
|
||||
{
|
||||
// Set the value
|
||||
$parsedCells[(string) $index] = $this->parseCell($index);
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
} catch (PHPExcel_Exception $e) {
|
||||
// silently ignore the 'No cells exist within the specified range' error, but rethrow any others
|
||||
if ($e->getMessage() != 'No cells exist within the specified range') {
|
||||
throw $e;
|
||||
}
|
||||
// make sure that we return an empty CellCollection
|
||||
$parsedCells = array();
|
||||
}
|
||||
|
||||
// Return array with parsed cells
|
||||
return new CellCollection($parsedCells);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a single cell
|
||||
* @param integer $index
|
||||
* @return string
|
||||
*/
|
||||
protected function parseCell($index)
|
||||
{
|
||||
// If the cell is a date time
|
||||
if ( $this->cellIsDate($index) )
|
||||
{
|
||||
// Parse the date
|
||||
return $this->parseDate();
|
||||
}
|
||||
|
||||
// Check if we want calculated values or not
|
||||
elseif ( $this->reader->needsCalculation() )
|
||||
{
|
||||
// Get calculated value
|
||||
return $this->getCalculatedValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get real value
|
||||
return $this->getCellValue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cell value
|
||||
* @return string
|
||||
*/
|
||||
protected function getCellValue()
|
||||
{
|
||||
$value = $this->cell->getValue();
|
||||
|
||||
return $this->encode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the calculated value
|
||||
* @return string
|
||||
*/
|
||||
protected function getCalculatedValue()
|
||||
{
|
||||
$value = $this->cell->getCalculatedValue();
|
||||
|
||||
return $this->encode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode with iconv
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
protected function encode($value)
|
||||
{
|
||||
// Get input and output encoding
|
||||
list($input, $output) = array_values(Config::get('excel.import.encoding', array('UTF-8', 'UTF-8')));
|
||||
|
||||
// If they are the same, return the value
|
||||
if ( $input == $output )
|
||||
return $value;
|
||||
|
||||
// Encode
|
||||
return iconv($input, $output, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the date
|
||||
* @return Carbon\Carbon|string
|
||||
*/
|
||||
protected function parseDate()
|
||||
{
|
||||
// If the date needs formatting
|
||||
if ( $this->reader->needsDateFormatting() )
|
||||
{
|
||||
// Parse the date with carbon
|
||||
return $this->parseDateAsCarbon();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parse the date as a normal string
|
||||
return $this->parseDateAsString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse and return carbon object or formatted time string
|
||||
* @return Carbon\Carbon
|
||||
*/
|
||||
protected function parseDateAsCarbon()
|
||||
{
|
||||
// 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');
|
||||
|
||||
// Parse with carbon
|
||||
$date = Carbon::parse($date);
|
||||
|
||||
// Format the date if wanted
|
||||
return $this->reader->getDateFormat() ? $date->format($this->reader->getDateFormat()) : $date;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return date string
|
||||
* @return string
|
||||
*/
|
||||
protected function parseDateAsString()
|
||||
{
|
||||
//Format the date to a formatted string
|
||||
return (string) PHPExcel_Style_NumberFormat::toFormattedString(
|
||||
$this->cell->getCalculatedValue(),
|
||||
$this->cell->getWorksheet()->getParent()
|
||||
->getCellXfByIndex($this->cell->getXfIndex())
|
||||
->getNumberFormat()
|
||||
->getFormatCode()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if cell is a date
|
||||
* @param integer $index
|
||||
* @return boolean
|
||||
*/
|
||||
protected function cellIsDate($index)
|
||||
{
|
||||
// if is a date or if is a date column
|
||||
if ( $this->reader->getDateColumns() )
|
||||
{
|
||||
return in_array($index, $this->reader->getDateColumns());
|
||||
}
|
||||
else
|
||||
{
|
||||
return PHPExcel_Shared_Date::isDateTime($this->cell);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if cells needs parsing
|
||||
* @return array
|
||||
*/
|
||||
protected function cellNeedsParsing($index)
|
||||
{
|
||||
// if no columns are selected or if the column is selected
|
||||
return !$this->hasSelectedColumns() || ($this->hasSelectedColumns() && in_array($index, $this->getSelectedColumns()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cell index from column
|
||||
* @return integer
|
||||
*/
|
||||
protected function getIndexFromColumn()
|
||||
{
|
||||
return PHPExcel_Cell::columnIndexFromString($this->cell->getColumn());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set selected columns
|
||||
* @param array $columns
|
||||
*/
|
||||
protected function setSelectedColumns($columns = array())
|
||||
{
|
||||
// Set the columns
|
||||
$this->columns = $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we have selected columns
|
||||
* @return boolean
|
||||
*/
|
||||
protected function hasSelectedColumns()
|
||||
{
|
||||
return !empty($this->columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set selected columns
|
||||
* @return array
|
||||
*/
|
||||
protected function getSelectedColumns()
|
||||
{
|
||||
// Set the columns
|
||||
return $this->columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset
|
||||
* @return void
|
||||
*/
|
||||
protected function reset()
|
||||
{
|
||||
$this->indices = array();
|
||||
$this->isParsed = false;
|
||||
}
|
||||
}
|
126
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/ViewParser.php
vendored
Normal file
126
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/ViewParser.php
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php namespace Maatwebsite\Excel\Parsers;
|
||||
|
||||
use Maatwebsite\Excel\Readers\Html;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel ViewParser
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class ViewParser {
|
||||
|
||||
/**
|
||||
* View file
|
||||
* @var string
|
||||
*/
|
||||
public $view;
|
||||
|
||||
/**
|
||||
* Data array
|
||||
* @var array
|
||||
*/
|
||||
public $data = array();
|
||||
|
||||
/**
|
||||
* View merge data
|
||||
* @var array
|
||||
*/
|
||||
public $mergeData = array();
|
||||
|
||||
/**
|
||||
* Construct the view parser
|
||||
* @param Html $reader
|
||||
* @return \Maatwebsite\Excel\Parsers\ViewParser
|
||||
*/
|
||||
public function __construct(Html $reader)
|
||||
{
|
||||
$this->reader = $reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the view
|
||||
* @param \Maatwebsite\Excel\Classes\LaravelExcelWorksheet $sheet
|
||||
* @return \Maatwebsite\Excel\Classes\LaravelExcelWorksheet
|
||||
*/
|
||||
public function parse($sheet)
|
||||
{
|
||||
$html = View::make($this->getView(), $this->getData(), $this->getMergeData())->render();
|
||||
|
||||
return $this->_loadHTML($sheet, $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the HTML
|
||||
* @param \Maatwebsite\Excel\Classes\LaravelExcelWorksheet $sheet
|
||||
* @param string $html
|
||||
* @return \Maatwebsite\Excel\Classes\LaravelExcelWorksheet
|
||||
*/
|
||||
protected function _loadHTML($sheet, $html)
|
||||
{
|
||||
return $this->reader->load($html, true, $sheet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view
|
||||
* @return string
|
||||
*/
|
||||
public function getView()
|
||||
{
|
||||
return $this->view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get merge data
|
||||
* @return array
|
||||
*/
|
||||
public function getMergeData()
|
||||
{
|
||||
return $this->mergeData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the view
|
||||
* @param bool|string $view
|
||||
*/
|
||||
public function setView($view = false)
|
||||
{
|
||||
if ($view)
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the data
|
||||
* @param array $data
|
||||
*/
|
||||
public function setData($data = array())
|
||||
{
|
||||
if (!empty($data))
|
||||
$this->data = array_merge($this->data, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the merge data
|
||||
* @param array $mergeData
|
||||
*/
|
||||
public function setMergeData($mergeData = array())
|
||||
{
|
||||
if (!empty($mergeData))
|
||||
$this->mergeData = array_merge($this->mergeData, $mergeData);
|
||||
}
|
||||
}
|
148
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/Batch.php
vendored
Normal file
148
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/Batch.php
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php namespace Maatwebsite\Excel\Readers;
|
||||
|
||||
use Closure;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel Batch Importer
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class Batch {
|
||||
|
||||
/**
|
||||
* Excel object
|
||||
* @var Excel
|
||||
*/
|
||||
protected $excel;
|
||||
|
||||
/**
|
||||
* Batch files
|
||||
* @var array
|
||||
*/
|
||||
public $files = array();
|
||||
|
||||
/**
|
||||
* Set allowed file extensions
|
||||
* @var array
|
||||
*/
|
||||
protected $allowedFileExtensions = array(
|
||||
'xls',
|
||||
'xlsx',
|
||||
'csv'
|
||||
);
|
||||
|
||||
/**
|
||||
* Start the Batach
|
||||
* @param Excel $excel
|
||||
* @param array $files
|
||||
* @param Closure $callback
|
||||
* @return Excel
|
||||
*/
|
||||
public function start(Excel $excel, $files, Closure $callback)
|
||||
{
|
||||
// Set excel object
|
||||
$this->excel = $excel;
|
||||
|
||||
// Set files
|
||||
$this->_setFiles($files);
|
||||
|
||||
// Do the callback
|
||||
if ($callback instanceof Closure)
|
||||
{
|
||||
foreach ($this->getFiles() as $file)
|
||||
{
|
||||
// Load the file
|
||||
$excel = $this->excel->load($file);
|
||||
|
||||
// Do a callback with the loaded file
|
||||
call_user_func($callback, $excel, $file);
|
||||
}
|
||||
}
|
||||
|
||||
// Return our excel object
|
||||
return $this->excel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the files
|
||||
* @return array
|
||||
*/
|
||||
public function getFiles()
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the batch files
|
||||
* @param array|string $files
|
||||
* @throws LaravelExcelException
|
||||
* @return void
|
||||
*/
|
||||
protected function _setFiles($files)
|
||||
{
|
||||
// If the param is an array, these will be the files for the batch import
|
||||
if (is_array($files))
|
||||
{
|
||||
$this->files = $this->_getFilesByArray($files);
|
||||
}
|
||||
|
||||
// Get all the files inside a folder
|
||||
elseif (is_string($files))
|
||||
{
|
||||
$this->files = $this->_getFilesByFolder($files);
|
||||
}
|
||||
|
||||
// Check if files were found
|
||||
if (empty($this->files))
|
||||
throw new LaravelExcelException('[ERROR]: No files were found. Batch terminated.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set files by array
|
||||
* @param array $array
|
||||
* @return array
|
||||
*/
|
||||
protected function _getFilesByArray($array)
|
||||
{
|
||||
$files = array();
|
||||
// Make sure we have real paths
|
||||
foreach ($array as $i => $file)
|
||||
{
|
||||
$files[$i] = realpath($file) ? $file : base_path($file);
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all files inside a folder
|
||||
* @param string $folder
|
||||
* @return array
|
||||
*/
|
||||
protected function _getFilesByFolder($folder)
|
||||
{
|
||||
// Check if it's a real path
|
||||
if (!realpath($folder))
|
||||
$folder = base_path($folder);
|
||||
|
||||
// Find path names matching our pattern of excel extensions
|
||||
$glob = glob($folder . '/*.{' . implode(',', $this->allowedFileExtensions) . '}', GLOB_BRACE);
|
||||
|
||||
// If no matches, return empty array
|
||||
if ($glob === false) return array();
|
||||
|
||||
// Return files
|
||||
return array_filter($glob, function ($file)
|
||||
{
|
||||
return filetype($file) == 'file';
|
||||
});
|
||||
}
|
||||
}
|
113
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/ChunkedReadJob.php
vendored
Normal file
113
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/ChunkedReadJob.php
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace Maatwebsite\Excel\Readers;
|
||||
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Maatwebsite\Excel\Filters\ChunkReadFilter;
|
||||
use SuperClosure\Serializer;
|
||||
|
||||
class ChunkedReadJob implements ShouldQueue
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $startRow;
|
||||
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
private $callback;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
private $chunkSize;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
private $startIndex;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
private $file;
|
||||
|
||||
/**
|
||||
* @var null
|
||||
*/
|
||||
private $sheets;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $shouldQueue;
|
||||
|
||||
/**
|
||||
* ChunkedReadJob constructor.
|
||||
*
|
||||
* @param $file
|
||||
* @param null $sheets
|
||||
* @param int $startRow
|
||||
* @param $startIndex
|
||||
* @param $chunkSize
|
||||
* @param callable $callback
|
||||
* @param bool $shouldQueue
|
||||
*/
|
||||
public function __construct(
|
||||
$file,
|
||||
$sheets = null,
|
||||
$startRow,
|
||||
$startIndex,
|
||||
$chunkSize,
|
||||
callable $callback,
|
||||
$shouldQueue = true
|
||||
) {
|
||||
$this->startRow = $startRow;
|
||||
$this->chunkSize = $chunkSize;
|
||||
$this->startIndex = $startIndex;
|
||||
$this->file = $file;
|
||||
|
||||
$this->callback = $shouldQueue ? (new Serializer)->serialize($callback) : $callback;
|
||||
$this->sheets = $sheets;
|
||||
$this->shouldQueue = $shouldQueue;
|
||||
}
|
||||
|
||||
/***
|
||||
* Handle the read job
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$reader = app('excel.reader');
|
||||
$reader->injectExcel(app('phpexcel'));
|
||||
$reader->_init($this->file);
|
||||
|
||||
$filter = new ChunkReadFilter();
|
||||
$reader->reader->setLoadSheetsOnly($this->sheets);
|
||||
$reader->reader->setReadFilter($filter);
|
||||
$reader->reader->setReadDataOnly(true);
|
||||
|
||||
// Set the rows for the chunking
|
||||
$filter->setRows($this->startRow, $this->chunkSize);
|
||||
|
||||
// Load file with chunk filter enabled
|
||||
$reader->excel = $reader->reader->load($this->file);
|
||||
|
||||
// Slice the results
|
||||
$results = $reader->get()->slice($this->startIndex, $this->chunkSize);
|
||||
|
||||
$callback = $this->shouldQueue ? (new Serializer)->unserialize($this->callback) : $this->callback;
|
||||
|
||||
// Do a callback
|
||||
if (is_callable($callback)) {
|
||||
$break = call_user_func($callback, $results);
|
||||
}
|
||||
|
||||
$reader->_reset();
|
||||
unset($reader, $results);
|
||||
|
||||
if ($break) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
176
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/ConfigReader.php
vendored
Normal file
176
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/ConfigReader.php
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php namespace Maatwebsite\Excel\Readers;
|
||||
|
||||
use Closure;
|
||||
use PHPExcel;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Maatwebsite\Excel\Collections\SheetCollection;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel ConfigReader
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class ConfigReader {
|
||||
|
||||
/**
|
||||
* Excel object
|
||||
* @var PHPExcel
|
||||
*/
|
||||
public $excel;
|
||||
|
||||
/**
|
||||
* The sheet
|
||||
* @var LaravelExcelWorksheet
|
||||
*/
|
||||
public $sheet;
|
||||
|
||||
/**
|
||||
* The sheetname
|
||||
* @var string
|
||||
*/
|
||||
public $sheetName;
|
||||
|
||||
/**
|
||||
* Collection of sheets (through the config reader)
|
||||
* @var SheetCollection
|
||||
*/
|
||||
public $sheetCollection;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param PHPExcel $excel
|
||||
* @param string $config
|
||||
* @param callback $callback
|
||||
*/
|
||||
public function __construct(PHPExcel $excel, $config = 'excel.import', $callback = null)
|
||||
{
|
||||
// Set excel object
|
||||
$this->excel = $excel;
|
||||
|
||||
// config name
|
||||
$this->configName = $config;
|
||||
|
||||
// start
|
||||
$this->start($callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the import
|
||||
* @param bool|callable $callback $callback
|
||||
* @throws \PHPExcel_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function start($callback = false)
|
||||
{
|
||||
// Init a new sheet collection
|
||||
$this->sheetCollection = new SheetCollection();
|
||||
|
||||
// Get the sheet names
|
||||
if ($sheets = $this->excel->getSheetNames())
|
||||
{
|
||||
// Loop through the sheets
|
||||
foreach ($sheets as $index => $name)
|
||||
{
|
||||
// Set sheet name
|
||||
$this->sheetName = $name;
|
||||
|
||||
// Set sheet
|
||||
$this->sheet = $this->excel->setActiveSheetIndex($index);
|
||||
|
||||
// Do the callback
|
||||
if ($callback instanceof Closure)
|
||||
{
|
||||
call_user_func($callback, $this);
|
||||
}
|
||||
// If no callback, put it inside the sheet collection
|
||||
else
|
||||
{
|
||||
$this->sheetCollection->push(clone $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sheet collection
|
||||
* @return SheetCollection
|
||||
*/
|
||||
public function getSheetCollection()
|
||||
{
|
||||
return $this->sheetCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value by index
|
||||
* @param string $field
|
||||
* @return string|null
|
||||
*/
|
||||
protected function valueByIndex($field)
|
||||
{
|
||||
// Convert field name
|
||||
$field = snake_case($field);
|
||||
|
||||
// Get coordinate
|
||||
if ($coordinate = $this->getCoordinateByKey($field))
|
||||
{
|
||||
// return cell value by coordinate
|
||||
return $this->getCellValueByCoordinate($coordinate);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return cell value
|
||||
* @param string $coordinate
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getCellValueByCoordinate($coordinate)
|
||||
{
|
||||
if ($this->sheet)
|
||||
{
|
||||
if (str_contains($coordinate, ':'))
|
||||
{
|
||||
// We want to get a range of cells
|
||||
$values = $this->sheet->rangeToArray($coordinate);
|
||||
|
||||
return $values;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We want 1 specific cell
|
||||
return $this->sheet->getCell($coordinate)->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the coordinates from the config file
|
||||
* @param string $field
|
||||
* @return string|boolean
|
||||
*/
|
||||
protected function getCoordinateByKey($field)
|
||||
{
|
||||
return Config::get($this->configName . '.' . $this->sheetName . '.' . $field, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically get a value by config
|
||||
* @param string $field
|
||||
* @return string
|
||||
*/
|
||||
public function __get($field)
|
||||
{
|
||||
return $this->valueByIndex($field);
|
||||
}
|
||||
}
|
1367
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/HtmlReader.php
vendored
Normal file
1367
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/HtmlReader.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1275
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/LaravelExcelReader.php
vendored
Normal file
1275
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/LaravelExcelReader.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
247
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Writers/CellWriter.php
vendored
Normal file
247
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Writers/CellWriter.php
vendored
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php namespace Maatwebsite\Excel\Writers;
|
||||
|
||||
use Maatwebsite\Excel\Classes\LaravelExcelWorksheet;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel Excel writer
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class CellWriter {
|
||||
|
||||
/**
|
||||
* Current $sheet
|
||||
* @var LaravelExcelWorksheet
|
||||
*/
|
||||
public $sheet;
|
||||
|
||||
/**
|
||||
* Selected cells
|
||||
* @var array
|
||||
*/
|
||||
public $cells;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param array $cells
|
||||
* @param LaravelExcelWorksheet $sheet
|
||||
*/
|
||||
public function __construct($cells, LaravelExcelWorksheet $sheet)
|
||||
{
|
||||
$this->cells = $cells;
|
||||
$this->sheet = $sheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell value
|
||||
* @param [type] $value
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
// Only set cell value for single cells
|
||||
if (!str_contains($this->cells, ':'))
|
||||
{
|
||||
$this->sheet->setCellValue($this->cells, $value);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the background
|
||||
* @param string $color
|
||||
* @param string $type
|
||||
* @param string $colorType
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setBackground($color, $type = 'solid', $colorType = 'rgb')
|
||||
{
|
||||
return $this->setColorStyle('fill', $color, $type, $colorType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the font color
|
||||
* @param string $color
|
||||
* @param string $colorType
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setFontColor($color, $colorType = 'rgb')
|
||||
{
|
||||
return $this->setColorStyle('font', $color, false, $colorType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the font
|
||||
* @param $styles
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setFont($styles)
|
||||
{
|
||||
return $this->setStyle('font', $styles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font family
|
||||
* @param string $family
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setFontFamily($family)
|
||||
{
|
||||
return $this->setStyle('font', array(
|
||||
'name' => $family
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font size
|
||||
* @param string $size
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setFontSize($size)
|
||||
{
|
||||
return $this->setStyle('font', array(
|
||||
'size' => $size
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font weight
|
||||
* @param boolean|string $bold
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setFontWeight($bold = true)
|
||||
{
|
||||
return $this->setStyle('font', array(
|
||||
'bold' => ($bold == 'bold' || $bold) ? true : false
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border
|
||||
* @param string $top
|
||||
* @param bool|string $right
|
||||
* @param bool|string $bottom
|
||||
* @param bool|string $left
|
||||
* @return 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(
|
||||
'style' => $left,
|
||||
),
|
||||
'right' => array(
|
||||
'style' => $right,
|
||||
),
|
||||
'bottom' => array(
|
||||
'style' => $bottom,
|
||||
)
|
||||
);
|
||||
|
||||
return $this->setStyle('borders', $styles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text rotation
|
||||
* @param integer $alignment
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setTextRotation($degrees)
|
||||
{
|
||||
$style = $this->getCellStyle()->getAlignment()->setTextRotation($degrees);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the alignment
|
||||
* @param string $alignment
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setAlignment($alignment)
|
||||
{
|
||||
return $this->setStyle('alignment', array(
|
||||
'horizontal' => $alignment
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set vertical alignment
|
||||
* @param string $alignment
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setValignment($alignment)
|
||||
{
|
||||
return $this->setStyle('alignment', array(
|
||||
'vertical' => $alignment
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text indent
|
||||
* @param integer $indent
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setTextIndent($indent)
|
||||
{
|
||||
$style = $this->getCellStyle()->getAlignment()->setIndent((int)$indent);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the color style
|
||||
* @param $styleType
|
||||
* @param string $color
|
||||
* @param boolean $type
|
||||
* @param string $colorType
|
||||
* @return CellWriter
|
||||
*/
|
||||
protected function setColorStyle($styleType, $color, $type = false, $colorType = 'rgb')
|
||||
{
|
||||
// Set the styles
|
||||
$styles = is_array($color) ? $color : array(
|
||||
'type' => $type,
|
||||
'color' => array($colorType => str_replace('#', '', $color))
|
||||
);
|
||||
|
||||
return $this->setStyle($styleType, $styles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set style
|
||||
* @param $styleType
|
||||
* @param string $styles
|
||||
* @return CellWriter
|
||||
*/
|
||||
protected function setStyle($styleType, $styles)
|
||||
{
|
||||
// Get the cell style
|
||||
$style = $this->getCellStyle();
|
||||
|
||||
// Apply style from array
|
||||
$style->applyFromArray(array(
|
||||
$styleType => $styles
|
||||
));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cell style
|
||||
* @return \PHPExcel_Style
|
||||
*/
|
||||
protected function getCellStyle()
|
||||
{
|
||||
return $this->sheet->getStyle($this->cells);
|
||||
}
|
||||
}
|
642
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Writers/LaravelExcelWriter.php
vendored
Normal file
642
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Writers/LaravelExcelWriter.php
vendored
Normal file
@@ -0,0 +1,642 @@
|
||||
<?php namespace Maatwebsite\Excel\Writers;
|
||||
|
||||
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;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
use Symfony\Component\Finder\Exception\AccessDeniedException;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel Excel writer
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class LaravelExcelWriter {
|
||||
|
||||
/**
|
||||
* Spreadsheet filename
|
||||
* @var string
|
||||
*/
|
||||
public $filename;
|
||||
|
||||
/**
|
||||
* Spreadsheet title
|
||||
* @var string
|
||||
*/
|
||||
public $title;
|
||||
|
||||
/**
|
||||
* Excel object
|
||||
* @var \PHPExcel
|
||||
*/
|
||||
public $excel;
|
||||
|
||||
/**
|
||||
* Laravel response
|
||||
* @var Response
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* Spreadsheet writer
|
||||
* @var object
|
||||
*/
|
||||
public $writer;
|
||||
|
||||
/**
|
||||
* Excel sheet
|
||||
* @var LaravelExcelWorksheet
|
||||
*/
|
||||
protected $sheet;
|
||||
|
||||
/**
|
||||
* Parser
|
||||
* @var ViewParser
|
||||
*/
|
||||
public $parser;
|
||||
|
||||
/**
|
||||
* Default extension
|
||||
* @var string
|
||||
*/
|
||||
public $ext = 'xls';
|
||||
|
||||
/**
|
||||
* Path the file will be stored to
|
||||
* @var string
|
||||
*/
|
||||
public $storagePath = 'exports';
|
||||
|
||||
/**
|
||||
* Header Content-type
|
||||
* @var string
|
||||
*/
|
||||
protected $contentType;
|
||||
|
||||
/**
|
||||
* Spreadsheet is rendered
|
||||
* @var boolean
|
||||
*/
|
||||
protected $rendered = false;
|
||||
|
||||
/**
|
||||
* Construct writer
|
||||
* @param Response $response
|
||||
* @param FileSystem $filesystem
|
||||
* @param FormatIdentifier $identifier
|
||||
*/
|
||||
public function __construct(Response $response, FileSystem $filesystem, FormatIdentifier $identifier)
|
||||
{
|
||||
$this->response = $response;
|
||||
$this->filesystem = $filesystem;
|
||||
$this->identifier = $identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject the excel object
|
||||
* @param PHPExcel $excel
|
||||
* @param bool $reset
|
||||
* @return void
|
||||
*/
|
||||
public function injectExcel($excel, $reset = true)
|
||||
{
|
||||
$this->excel = $excel;
|
||||
|
||||
if ($reset)
|
||||
$this->_reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the spreadsheet title
|
||||
* @param string $title
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->getProperties()->setTitle($title);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the filename
|
||||
* @param $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setFileName($name)
|
||||
{
|
||||
$this->filename = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title
|
||||
* @return string
|
||||
*/
|
||||
public function getFileName()
|
||||
{
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Share view with all sheets
|
||||
* @param string $view
|
||||
* @param array $data
|
||||
* @param array $mergeData
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function shareView($view, $data = array(), $mergeData = array())
|
||||
{
|
||||
// Get the parser
|
||||
$this->getParser();
|
||||
|
||||
// Set the view inside the parser
|
||||
$this->parser->setView($view);
|
||||
$this->parser->setData($data);
|
||||
$this->parser->setMergeData($mergeData);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the view
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function setView()
|
||||
{
|
||||
return call_user_func_array(array($this, 'shareView'), func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the view
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function loadView()
|
||||
{
|
||||
return call_user_func_array(array($this, 'shareView'), func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new sheet
|
||||
* @param string $title
|
||||
* @param callback|null $callback
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function sheet($title, $callback = null)
|
||||
{
|
||||
// Clone the active sheet
|
||||
$this->sheet = $this->excel->createSheet(null, $title);
|
||||
|
||||
// If a parser was set, inject it
|
||||
if ($this->parser)
|
||||
$this->sheet->setParser($this->parser);
|
||||
|
||||
// Set the sheet title
|
||||
$this->sheet->setTitle($title);
|
||||
|
||||
// Set the default page setup
|
||||
$this->sheet->setDefaultPageSetup();
|
||||
|
||||
// Do the callback
|
||||
if ($callback instanceof Closure)
|
||||
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));
|
||||
|
||||
// Parse the sheet
|
||||
$this->sheet->parsed();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set data for the current sheet
|
||||
* @param array $array
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function with(Array $array)
|
||||
{
|
||||
// Add the vars
|
||||
$this->fromArray($array);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the spreadsheet
|
||||
* @param string $ext
|
||||
* @param array $headers
|
||||
* @throws LaravelExcelException
|
||||
*/
|
||||
public function export($ext = 'xls', Array $headers = array())
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
// Render the file
|
||||
$this->_render();
|
||||
|
||||
// Download the file
|
||||
$this->_download($headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert and existing file to newly requested extension
|
||||
* @param $ext
|
||||
* @param array $headers
|
||||
*/
|
||||
public function convert($ext, Array $headers = array())
|
||||
{
|
||||
$this->export($ext, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export and download the spreadsheet
|
||||
* @param string $ext
|
||||
* @param array $headers
|
||||
*/
|
||||
public function download($ext = 'xls', Array $headers = array())
|
||||
{
|
||||
$this->export($ext, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the spreadsheet file as a string
|
||||
* @param string $ext
|
||||
* @return string
|
||||
* @throws LaravelExcelException
|
||||
*/
|
||||
public function string($ext = 'xls')
|
||||
{
|
||||
// Set the extension
|
||||
$this->ext = $ext;
|
||||
|
||||
// Render the file
|
||||
$this->_render();
|
||||
|
||||
// Check if writer isset
|
||||
if (!$this->writer)
|
||||
throw new LaravelExcelException('[ERROR] No writer was set.');
|
||||
|
||||
//Capture the content as a string and return it
|
||||
ob_start();
|
||||
|
||||
$this->writer->save('php://output');
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Download a file
|
||||
* @param array $headers
|
||||
* @throws LaravelExcelException
|
||||
*/
|
||||
protected function _download(Array $headers = array())
|
||||
{
|
||||
// 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
|
||||
if (!$this->writer)
|
||||
throw new LaravelExcelException('[ERROR] No writer was set.');
|
||||
|
||||
|
||||
// Download
|
||||
$this->writer->save('php://output');
|
||||
|
||||
// End the script to prevent corrupted xlsx files
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the excel file to the server
|
||||
* @param string $ext
|
||||
* @param boolean $path
|
||||
* @param boolean $returnInfo
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function store($ext = 'xls', $path = false, $returnInfo = false)
|
||||
{
|
||||
// Set the storage path
|
||||
$this->_setStoragePath($path);
|
||||
|
||||
// Set the extension
|
||||
$this->ext = $ext;
|
||||
|
||||
// Render the XLS
|
||||
$this->_render();
|
||||
|
||||
// Set the storage path and file
|
||||
$toStore = $this->storagePath . '/' . $this->filename . '.' . $this->ext;
|
||||
|
||||
// Save the file to specified location
|
||||
$this->writer->save($toStore);
|
||||
|
||||
// Return file info
|
||||
if ($this->returnInfo($returnInfo))
|
||||
{
|
||||
// Send back information about the stored file
|
||||
return array(
|
||||
'full' => $toStore,
|
||||
'path' => $this->storagePath,
|
||||
'file' => $this->filename . '.' . $this->ext,
|
||||
'title' => $this->filename,
|
||||
'ext' => $this->ext
|
||||
);
|
||||
}
|
||||
|
||||
// Return itself
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we want to return info or itself
|
||||
* @param boolean $returnInfo
|
||||
* @return boolean
|
||||
*/
|
||||
public function returnInfo($returnInfo = false)
|
||||
{
|
||||
return $returnInfo ? $returnInfo : Config::get('excel.export.store.returnInfo', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the excel file to the server
|
||||
* @param str|string $ext The file extension
|
||||
* @param bool|str $path The save path
|
||||
* @param bool $returnInfo
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function save($ext = 'xls', $path = false, $returnInfo = false)
|
||||
{
|
||||
return $this->store($ext, $path, $returnInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start render of a new spreadsheet
|
||||
* @throws LaravelExcelException
|
||||
* @return void
|
||||
*/
|
||||
protected function _render()
|
||||
{
|
||||
// There should be enough sheets to continue rendering
|
||||
if ($this->excel->getSheetCount() < 0)
|
||||
throw new LaravelExcelException('[ERROR] Aborting spreadsheet render: no sheets were created.');
|
||||
|
||||
// Set the format
|
||||
$this->_setFormat();
|
||||
|
||||
// Set the writer
|
||||
$this->_setWriter();
|
||||
|
||||
// File has been rendered
|
||||
$this->rendered = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view parser
|
||||
* @return PHPExcel
|
||||
*/
|
||||
public function getExcel()
|
||||
{
|
||||
return $this->excel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view parser
|
||||
* @return ViewParser
|
||||
*/
|
||||
public function getParser()
|
||||
{
|
||||
// Init the parser
|
||||
if (!$this->parser)
|
||||
$this->parser = app('excel.parsers.view');
|
||||
|
||||
return $this->parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sheet
|
||||
* @return LaravelExcelWorksheet
|
||||
*/
|
||||
public function getSheet()
|
||||
{
|
||||
return $this->sheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set attributes
|
||||
* @param string $setter
|
||||
* @param array $params
|
||||
*/
|
||||
protected function _setAttribute($setter, $params)
|
||||
{
|
||||
// Get the key
|
||||
$key = lcfirst(str_replace('set', '', $setter));
|
||||
|
||||
// If is an allowed property
|
||||
if ($this->excel->isChangeableProperty($setter))
|
||||
{
|
||||
// Set the properties
|
||||
call_user_func_array(array($this->excel->getProperties(), $setter), $params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the write format
|
||||
* @return void
|
||||
*/
|
||||
protected function _setFormat()
|
||||
{
|
||||
// Get extension
|
||||
$this->ext = strtolower($this->ext);
|
||||
|
||||
// get the file format
|
||||
$this->format = $this->identifier->getFormatByExtension($this->ext);
|
||||
|
||||
// Get content type
|
||||
$this->contentType = $this->identifier->getContentTypeByFormat($this->format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the writer
|
||||
* @return PHPExcel_***_Writer
|
||||
*/
|
||||
protected function _setWriter()
|
||||
{
|
||||
// Set pdf renderer
|
||||
if ($this->format == 'PDF')
|
||||
{
|
||||
$this->setPdfRenderer();
|
||||
}
|
||||
|
||||
// Create the writer
|
||||
$this->writer = PHPExcel_IOFactory::createWriter($this->excel, $this->format);
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
// Set CSV delimiter
|
||||
if ($this->format == 'PDF')
|
||||
{
|
||||
$this->writer->writeAllSheets();
|
||||
}
|
||||
|
||||
// Calculation settings
|
||||
$this->writer->setPreCalculateFormulas(Config::get('excel.export.calculate', false));
|
||||
|
||||
// Include Charts
|
||||
$this->writer->setIncludeCharts(Config::get('excel.export.includeCharts', false));
|
||||
|
||||
return $this->writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the pdf renderer
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function setPdfRenderer()
|
||||
{
|
||||
// Get the driver name
|
||||
$driver = Config::get('excel.export.pdf.driver');
|
||||
$path = Config::get('excel.export.pdf.drivers.' . $driver . '.path');
|
||||
|
||||
// Disable autoloading for dompdf
|
||||
if(! defined("DOMPDF_ENABLE_AUTOLOAD")){
|
||||
define("DOMPDF_ENABLE_AUTOLOAD", false);
|
||||
}
|
||||
|
||||
// Set the pdf renderer
|
||||
if (!\PHPExcel_Settings::setPdfRenderer($driver, $path))
|
||||
throw new \Exception("{$driver} could not be found. Make sure you've included it in your composer.json");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the headers
|
||||
* @param $headers
|
||||
* @throws LaravelExcelException
|
||||
*/
|
||||
protected function _setHeaders(Array $headers = array(), Array $default)
|
||||
{
|
||||
if (headers_sent()) throw new LaravelExcelException('[ERROR]: Headers already sent');
|
||||
|
||||
// Merge the default headers with the overruled headers
|
||||
$headers = array_merge($default, $headers);
|
||||
|
||||
foreach ($headers as $header => $value)
|
||||
{
|
||||
header($header . ': ' . $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the storage path
|
||||
* @param bool $path
|
||||
* @return void
|
||||
*/
|
||||
protected function _setStoragePath($path = false)
|
||||
{
|
||||
// Get the default path
|
||||
$path = $path ? $path : Config::get('excel.export.store.path', storage_path($this->storagePath));
|
||||
|
||||
// Trim of slashes, to makes sure we won't add them double
|
||||
$this->storagePath = rtrim($path, '/');
|
||||
|
||||
// Make sure the storage path exists
|
||||
if (!$this->filesystem->exists($this->storagePath)) {
|
||||
$this->filesystem->makeDirectory($this->storagePath, 0777, true);
|
||||
}
|
||||
|
||||
if (!$this->filesystem->isWritable($this->storagePath)) {
|
||||
throw new LaravelExcelException("Permission denied to the storage path");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the writer
|
||||
* @return void
|
||||
*/
|
||||
protected function _reset()
|
||||
{
|
||||
$this->excel->disconnectWorksheets();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call methods
|
||||
* @param string $method
|
||||
* @param array $params
|
||||
* @throws LaravelExcelException
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function __call($method, $params)
|
||||
{
|
||||
// If the dynamic call starts with "set"
|
||||
if (starts_with($method, 'set') && $this->excel->isChangeableProperty($method))
|
||||
{
|
||||
$this->_setAttribute($method, $params);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// Call a php excel method
|
||||
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 $return ? $return : $this;
|
||||
}
|
||||
|
||||
throw new LaravelExcelException('[ERROR] Writer method [' . $method . '] does not exist.');
|
||||
}
|
||||
}
|
691
vendor/maatwebsite/excel/src/config/excel.php
vendored
Normal file
691
vendor/maatwebsite/excel/src/config/excel.php
vendored
Normal file
@@ -0,0 +1,691 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
|
||||
'cache' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable/Disable cell caching
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'enable' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Caching driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Set the caching driver
|
||||
|
|
||||
| Available methods:
|
||||
| memory|gzip|serialized|igbinary|discISAM|apc|memcache|temp|wincache|sqlite|sqlite3
|
||||
|
|
||||
*/
|
||||
'driver' => 'memory',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'settings' => array(
|
||||
|
||||
'memoryCacheSize' => '32MB',
|
||||
'cacheTime' => 600
|
||||
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Memcache settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'memcache' => array(
|
||||
|
||||
'host' => 'localhost',
|
||||
'port' => 11211,
|
||||
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache dir (for discISAM)
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'dir' => storage_path('cache')
|
||||
),
|
||||
|
||||
'properties' => array(
|
||||
'creator' => 'Maatwebsite',
|
||||
'lastModifiedBy' => 'Maatwebsite',
|
||||
'title' => 'Spreadsheet',
|
||||
'description' => 'Default spreadsheet export',
|
||||
'subject' => 'Spreadsheet export',
|
||||
'keywords' => 'maatwebsite, excel, export',
|
||||
'category' => 'Excel',
|
||||
'manager' => 'Maatwebsite',
|
||||
'company' => 'Maatwebsite',
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sheets settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'sheets' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default page setup
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'pageSetup' => array(
|
||||
'orientation' => 'portrait',
|
||||
'paperSize' => '9',
|
||||
'scale' => '100',
|
||||
'fitToPage' => false,
|
||||
'fitToHeight' => true,
|
||||
'fitToWidth' => true,
|
||||
'columnsToRepeatAtLeft' => array('', ''),
|
||||
'rowsToRepeatAtTop' => array(0, 0),
|
||||
'horizontalCentered' => false,
|
||||
'verticalCentered' => false,
|
||||
'printArea' => null,
|
||||
'firstPageNumber' => null,
|
||||
),
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Creator
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The default creator of a new Excel file
|
||||
|
|
||||
*/
|
||||
|
||||
'creator' => 'Maatwebsite',
|
||||
|
||||
'csv' => array(
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Delimiter
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The default delimiter which will be used to read out a CSV file
|
||||
|
|
||||
*/
|
||||
|
||||
'delimiter' => ',',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enclosure
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'enclosure' => '"',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Line endings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'line_ending' => "\r\n",
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| setUseBom
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'use_bom' => false
|
||||
),
|
||||
|
||||
'export' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autosize columns
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Disable/enable column autosize or set the autosizing for
|
||||
| an array of columns ( array('A', 'B') )
|
||||
|
|
||||
*/
|
||||
'autosize' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autosize method
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX
|
||||
| The default is based on an estimate, which does its calculation based
|
||||
| on the number of characters in the cell value (applying any calculation
|
||||
| and format mask, and allowing for wordwrap and rotation) and with an
|
||||
| "arbitrary" adjustment based on the font (Arial, Calibri or Verdana,
|
||||
| defaulting to Calibri if any other font is used) and a proportional
|
||||
| adjustment for the font size.
|
||||
|
|
||||
| --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT
|
||||
| The second method is more accurate, based on actual style formatting as
|
||||
| well (bold, italic, etc), and is calculated by generating a gd2 imagettf
|
||||
| bounding box and using its dimensions to determine the size; but this
|
||||
| method is significantly slower, and its accuracy is still dependent on
|
||||
| having the appropriate fonts installed.
|
||||
|
|
||||
*/
|
||||
'autosize-method' => PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Auto generate table heading
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If set to true, the array indices (or model attribute names)
|
||||
| will automatically be used as first row (table heading)
|
||||
|
|
||||
*/
|
||||
'generate_heading_by_indices' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Auto set alignment on merged cells
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'merged_cell_alignment' => 'left',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Pre-calculate formulas during export
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'calculate' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Include Charts during export
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'includeCharts' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default sheet settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'sheets' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default page margin
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| 1) When set to false, default margins will be used
|
||||
| 2) It's possible to enter a single margin which will
|
||||
| be used for all margins.
|
||||
| 3) Alternatively you can pass an array with 4 margins
|
||||
| Default order: array(top, right, bottom, left)
|
||||
|
|
||||
*/
|
||||
'page_margin' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Value in source array that stands for blank cell
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'nullValue' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Insert array starting from this cell address as the top left coordinate
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'startCell' => 'A1',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Apply strict comparison when testing for null values in the array
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'strictNullComparison' => false
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Store settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'store' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The path we want to save excel file to
|
||||
|
|
||||
*/
|
||||
'path' => storage_path('exports'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Return info
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Whether we want to return information about the stored file or not
|
||||
|
|
||||
*/
|
||||
'returnInfo' => false
|
||||
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PDF Settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'pdf' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PDF Drivers
|
||||
|--------------------------------------------------------------------------
|
||||
| Supported: DomPDF, tcPDF, mPDF
|
||||
*/
|
||||
'driver' => 'DomPDF',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PDF Driver settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'drivers' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DomPDF settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'DomPDF' => array(
|
||||
'path' => base_path('vendor/dompdf/dompdf/')
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| tcPDF settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'tcPDF' => array(
|
||||
'path' => base_path('vendor/tecnick.com/tcpdf/')
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| mPDF settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'mPDF' => array(
|
||||
'path' => base_path('vendor/mpdf/mpdf/')
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
'filters' => array(
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register read filters
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'registered' => array(
|
||||
'chunk' => 'Maatwebsite\Excel\Filters\ChunkReadFilter'
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable certain filters for every file read
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'enabled' => array()
|
||||
),
|
||||
|
||||
'import' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Has heading
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The sheet has a heading (first) row which we can use as attribute names
|
||||
|
|
||||
| Options: true|false|slugged|slugged_with_count|ascii|numeric|hashed|trans|original
|
||||
|
|
||||
*/
|
||||
|
||||
'heading' => 'slugged',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| First Row with data or heading of data
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If the heading row is not the first row, or the data doesn't start
|
||||
| on the first row, here you can change the start row.
|
||||
|
|
||||
*/
|
||||
|
||||
'startRow' => 1,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cell name word separator
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The default separator which is used for the cell names
|
||||
| Note: only applies to 'heading' settings 'true' && 'slugged'
|
||||
|
|
||||
*/
|
||||
|
||||
'separator' => '_',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Include Charts during import
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'includeCharts' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sheet heading conversion
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Convert headings to ASCII
|
||||
| Note: only applies to 'heading' settings 'true' && 'slugged'
|
||||
|
|
||||
*/
|
||||
|
||||
'to_ascii' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Import encoding
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'encoding' => array(
|
||||
|
||||
'input' => 'UTF-8',
|
||||
'output' => 'UTF-8'
|
||||
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Calculate
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By default cells with formulas will be calculated.
|
||||
|
|
||||
*/
|
||||
|
||||
'calculate' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Ignore empty cells
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By default empty cells are not ignored
|
||||
|
|
||||
*/
|
||||
|
||||
'ignoreEmpty' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Force sheet collection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| For a sheet collection even when there is only 1 sheets.
|
||||
| When set to false and only 1 sheet found, the parsed file will return
|
||||
| a row collection instead of a sheet collection.
|
||||
| When set to true, it will return a sheet collection instead.
|
||||
|
|
||||
*/
|
||||
'force_sheets_collection' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Date format
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The format dates will be parsed to
|
||||
|
|
||||
*/
|
||||
|
||||
'dates' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable/disable date formatting
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'enabled' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default date format
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If set to false, a carbon object will return
|
||||
|
|
||||
*/
|
||||
'format' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Date columns
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'columns' => array()
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Import sheets by config
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'sheets' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Example sheet
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Example sheet "test" will grab the firstname at cell A2
|
||||
|
|
||||
*/
|
||||
|
||||
'test' => array(
|
||||
|
||||
'firstname' => 'A2'
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
),
|
||||
|
||||
'views' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Styles
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The default styles which will be used when parsing a view
|
||||
|
|
||||
*/
|
||||
|
||||
'styles' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Table headings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'th' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 12,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Strong tags
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'strong' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 12,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bold tags
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'b' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 12,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Italic tags
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'i' => array(
|
||||
'font' => array(
|
||||
'italic' => true,
|
||||
'size' => 12,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Heading 1
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'h1' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 24,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Heading 2
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'h2' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 18,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Heading 2
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'h3' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 13.5,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Heading 4
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'h4' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 12,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Heading 5
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'h5' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 10,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Heading 6
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'h6' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 7.5,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Hyperlinks
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'a' => array(
|
||||
'font' => array(
|
||||
'underline' => true,
|
||||
'color' => array('argb' => 'FF0000FF'),
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Horizontal rules
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'hr' => array(
|
||||
'borders' => array(
|
||||
'bottom' => array(
|
||||
'style' => 'thin',
|
||||
'color' => array('FF000000')
|
||||
),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
);
|
0
vendor/maatwebsite/excel/tests/.gitkeep
vendored
Normal file
0
vendor/maatwebsite/excel/tests/.gitkeep
vendored
Normal file
53
vendor/maatwebsite/excel/tests/Collections/CellCollectionTest.php
vendored
Normal file
53
vendor/maatwebsite/excel/tests/Collections/CellCollectionTest.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Maatwebsite\Excel\Collections\CellCollection;
|
||||
|
||||
class CellCollectionTest extends TestCase {
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->collection = new CellCollection([
|
||||
'one' => 'one',
|
||||
'two' => 'two'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function testSetItems()
|
||||
{
|
||||
$this->collection->setItems([
|
||||
'three' => 'three'
|
||||
]);
|
||||
|
||||
$this->assertContains('three', $this->collection);
|
||||
$this->assertCount(3, $this->collection);
|
||||
}
|
||||
|
||||
|
||||
public function testDynamicGetters()
|
||||
{
|
||||
$this->assertEquals('two', $this->collection->two);
|
||||
}
|
||||
|
||||
|
||||
public function testIsset()
|
||||
{
|
||||
$this->assertTrue(isset($this->collection->two));
|
||||
$this->assertFalse(isset($this->collection->nonexisting));
|
||||
}
|
||||
|
||||
|
||||
public function testEmpty()
|
||||
{
|
||||
$this->assertFalse(empty($this->collection->two));
|
||||
$this->assertTrue(empty($this->collection->nonexisting));
|
||||
}
|
||||
|
||||
|
||||
public function testDynamicCheck()
|
||||
{
|
||||
$this->assertTrue($this->collection->two ? true : false);
|
||||
$this->assertFalse($this->collection->nonexisting ? true : false);
|
||||
}
|
||||
}
|
111
vendor/maatwebsite/excel/tests/Excel/ExcelTestCase.php
vendored
Normal file
111
vendor/maatwebsite/excel/tests/Excel/ExcelTestCase.php
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
use Mockery as m;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
|
||||
class ExcelTestCase extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* Mocks
|
||||
* @var [type]
|
||||
*/
|
||||
public $phpexcel;
|
||||
public $reader;
|
||||
public $writer;
|
||||
public $excel;
|
||||
public $batch;
|
||||
|
||||
/**
|
||||
* Setup test case
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Set the mocks
|
||||
$this->setMocks();
|
||||
|
||||
// Init our excel class
|
||||
$this->excel = new Excel($this->phpexcel, $this->reader, $this->writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the constructor
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Excel', $this->excel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mocks
|
||||
*/
|
||||
public function setMocks()
|
||||
{
|
||||
$this->mockPHPExcel();
|
||||
$this->mockReader();
|
||||
$this->mockWriter();
|
||||
$this->mockBatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mock PHPExcel class
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function mockPHPExcel()
|
||||
{
|
||||
$this->phpexcel = m::mock('Maatwebsite\Excel\Classes\PHPExcel');
|
||||
$this->phpexcel->shouldReceive('getID');
|
||||
$this->phpexcel->shouldReceive('disconnectWorksheets');
|
||||
$this->phpexcel->shouldReceive('setDefaultProperties');
|
||||
}
|
||||
|
||||
/**
|
||||
* Mock Reader class
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function mockReader()
|
||||
{
|
||||
$this->reader = m::mock('Maatwebsite\Excel\Readers\LaravelExcelReader');
|
||||
$this->reader->shouldReceive('injectExcel')->with($this->phpexcel);
|
||||
$this->reader->shouldReceive('load');
|
||||
$this->reader->shouldReceive('setSelectedSheets');
|
||||
$this->reader->shouldReceive('setSelectedSheetIndices');
|
||||
$this->reader->shouldReceive('setFilters');
|
||||
}
|
||||
|
||||
/**
|
||||
* Mock Writer class
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function mockWriter()
|
||||
{
|
||||
$this->writer = m::mock('Maatwebsite\Excel\Writers\LaravelExcelWriter');
|
||||
$this->writer->shouldReceive('injectExcel')->with($this->phpexcel);
|
||||
$this->writer->shouldReceive('setTitle');
|
||||
$this->writer->shouldReceive('setFileName');
|
||||
$this->writer->shouldReceive('shareView')->andReturn($this->writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mock Writer class
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function mockBatch()
|
||||
{
|
||||
$this->batch = m::mock('Maatwebsite\Excel\Readers\Batch');
|
||||
$this->batch->shouldReceive('start')->andReturn('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* Teardown
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
}
|
||||
|
||||
}
|
46
vendor/maatwebsite/excel/tests/Excel/ExcelTester.php
vendored
Normal file
46
vendor/maatwebsite/excel/tests/Excel/ExcelTester.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Mockery as m;
|
||||
|
||||
class ExcelTester extends ExcelTestCase {
|
||||
|
||||
/**
|
||||
* Test select sheets
|
||||
* @return
|
||||
*/
|
||||
public function testSelectSheets()
|
||||
{
|
||||
$selected = $this->excel->selectSheets(array('sheet'));
|
||||
$this->assertEquals($this->excel, $selected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test select sheets
|
||||
* @return
|
||||
*/
|
||||
public function testSelectSheetsByIndex()
|
||||
{
|
||||
$selected = $this->excel->selectSheetsByIndex(array('0'));
|
||||
$this->assertEquals($this->excel, $selected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the share view
|
||||
* @return
|
||||
*/
|
||||
public function testShareView()
|
||||
{
|
||||
$selected = $this->excel->shareView('filename', array('test'), array('test'));
|
||||
$this->assertEquals($this->writer, $selected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test load view
|
||||
* @return
|
||||
*/
|
||||
public function testLoadView()
|
||||
{
|
||||
$selected = $this->excel->loadView('filename', array('test'), array('test'));
|
||||
$this->assertEquals($this->writer, $selected);
|
||||
}
|
||||
}
|
24
vendor/maatwebsite/excel/tests/Files/CsvExcelFileTest.php
vendored
Normal file
24
vendor/maatwebsite/excel/tests/Files/CsvExcelFileTest.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
include_once 'classes/CsvTestImport.php';
|
||||
|
||||
class CsvExcelFileTest extends TestCase {
|
||||
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$importer = app('CsvTestImport');
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Files\ExcelFile', $importer);
|
||||
}
|
||||
|
||||
|
||||
public function testGetResultsDirectlyWithCustomDelimiterSetAsProperty()
|
||||
{
|
||||
$importer = app('TestImport');
|
||||
$results = $importer->get();
|
||||
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $results);
|
||||
$this->assertCount(5, $results);
|
||||
}
|
||||
|
||||
}
|
70
vendor/maatwebsite/excel/tests/Files/ExcelFileTest.php
vendored
Normal file
70
vendor/maatwebsite/excel/tests/Files/ExcelFileTest.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
include_once 'classes/TestImport.php';
|
||||
include_once 'classes/TestImportHandler.php';
|
||||
include_once 'classes/TestFile.php';
|
||||
include_once 'classes/TestFileHandler.php';
|
||||
|
||||
class ExcelFileTest extends TestCase {
|
||||
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$importer = app('TestImport');
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Files\ExcelFile', $importer);
|
||||
}
|
||||
|
||||
|
||||
public function testGetFile()
|
||||
{
|
||||
$importer = app('TestImport');
|
||||
$file = $importer->getFile();
|
||||
$exploded = explode('/',$file);
|
||||
$filename = end($exploded);
|
||||
|
||||
$this->assertEquals('test.csv', $filename);
|
||||
}
|
||||
|
||||
|
||||
public function testGetFilters()
|
||||
{
|
||||
$importer = app('TestImport');
|
||||
$this->assertContains('chunk', $importer->getFilters());
|
||||
$this->assertContains('chunk', $importer->getFileInstance()->filters['enabled']);
|
||||
}
|
||||
|
||||
|
||||
public function testLoadFile()
|
||||
{
|
||||
$importer = app('TestImport');
|
||||
$importer->loadFile();
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Readers\LaravelExcelReader', $importer->getFileInstance());
|
||||
}
|
||||
|
||||
|
||||
public function testGetResultsDirectly()
|
||||
{
|
||||
$importer = app('TestImport');
|
||||
$results = $importer->get();
|
||||
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $results);
|
||||
$this->assertCount(5, $results);
|
||||
}
|
||||
|
||||
|
||||
public function testImportHandler()
|
||||
{
|
||||
$importer = app('TestImport');
|
||||
$results = $importer->handleImport();
|
||||
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $results);
|
||||
$this->assertCount(5, $results);
|
||||
|
||||
$importer = app('TestFile');
|
||||
$results = $importer->handleImport();
|
||||
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $results);
|
||||
$this->assertCount(5, $results);
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user