Download the PHP package lab36/excel-report without Composer
On this page you can find all versions of the php package lab36/excel-report. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package excel-report
ExcelReport
This package allows you to generate Microsoft Excel files from any collection or array. You can easily apply formatting, styles or themes. It comes bundled with beautiful themes ready to use.
This php library is a wrapper around PhpSpreadsheet library.
Motivation
We needed to export beautiful excel reports and with as little boilerplate as possible. PhpSpreadsheet does a good job working with excel files and we needed something on top just to avoid the repetitive work.
✨ Features
-
Easily export collection/array to Excel. Take your Laravel collection/array and export them directly to an Excel document.
-
Beautiful themes ready to go. Beautiful templates easy customizable already prepared for you.
- Customize any cell. Hooks to easily customize any cell based on values or coordinates.
Basic Usage
Just create a file in anywhere in your app folder or use an artisan command:
This by default will create the file ProjectDetailsExcelReport.php with folder app\ExcelReport.
In your controller:
For more examples follow this link.
Installation
You can install the package via composer:
and then publish the config
Options
First thing you need the ExcelReport file. It's just a php class that extends ExcelReport. You can use
Column mappings
The ExcelReport file must have a columnMappings function. This function maps array/collection values to Spreadsheet columns.
Exemple: Let's say we have an array
the columnMappings function would be:
columnMappings values would become the header for the excel report. If you want to ignore a column from the array just omit it from columnMappings. You can also use translations here.
Column alignment
By default PhpSpreadsheet does a good job aligning data. If you want to provide some exceptions you can implement columnAlignment function and specify the alignment.
Possible values:
- LEFT
- RIGHT
- CENTER
- HORIZONTAL_GENERAL
- HORIZONTAL_LEFT
- HORIZONTAL_RIGHT
- HORIZONTAL_CENTER
- HORIZONTAL_CENTER_CONTINUOUS
- HORIZONTAL_JUSTIFY
- HORIZONTAL_FILL
- HORIZONTAL_DISTRIBUTED
You can specify only the columns for which you need to change the alignment.
Column formats
You can specify column formats by implementing the function columnFormats
- NUMERIC
- TEXT
- DATE_DD-MM-YYYY
- NUMERIC_FORMATTED
- DATE_YYYY-MM-DD
- CURRENCY_LEI
- FORMAT_GENERAL
- FORMAT_TEXT
- FORMAT_NUMBER
- FORMAT_NUMBER_00
- FORMAT_NUMBER_COMMA_SEPARATED1::FORMAT_NUMBER_COMMA_SEPARATED1,
- FORMAT_NUMBER_COMMA_SEPARATED2::FORMAT_NUMBER_COMMA_SEPARATED2,
- FORMAT_PERCENTAGE
- FORMAT_PERCENTAGE_00
- FORMAT_DATE_YYYYMMDD2
- FORMAT_DATE_YYYYMMDD
- FORMAT_DATE_DDMMYYYY
- FORMAT_DATE_DMYSLASH
- FORMAT_DATE_DMYMINUS
- FORMAT_DATE_DMMINUS
- FORMAT_DATE_MYMINUS
- FORMAT_DATE_XLSX14
- FORMAT_DATE_XLSX15
- FORMAT_DATE_XLSX16
- FORMAT_DATE_XLSX17
- FORMAT_DATE_XLSX22
- FORMAT_DATE_DATETIME
- FORMAT_DATE_TIME1
- FORMAT_DATE_TIME2
- FORMAT_DATE_TIME3
- FORMAT_DATE_TIME4
- FORMAT_DATE_TIME5
- FORMAT_DATE_TIME6
- FORMAT_DATE_TIME7
- FORMAT_DATE_TIME8
- FORMAT_DATE_YYYYMMDDSLASH
- FORMAT_CURRENCY_USD_SIMPLE
- FORMAT_CURRENCY_USD
- FORMAT_CURRENCY_EUR_SIMPLE
- FORMAT_CURRENCY_EUR
You can also specify any PhpSpreadsheet format by using the function addColumnFormats(), which will merge default formats with the one specified.
Column width
You can define any custom column width in character units implementing the following function.
By default PhpSpreadsheet tries to guess the correct width for the column but there are cases when they become too long so we need to adjust. When a column gets smaller width, data in that column will wrap. Depending on your settings (default_row_height) rows will adjust to wrapping.
Special row positioning
You can override the default positioning for title, header and filters. For this you must call the coresponding setters.
In your Controller you can have
Choosing a theme
This package comes with two themes. The default theme is set in the config file. You can create other themes by implementing ExcelThemeInterface.
Filter reports
This filters represent the values used to obtain data for the report. If the filter doesn't have a corresponding column it will appear after the last column.
Filters are an array in form:
[column_name => filter_value, ...]
Download/store
You can choose to download or store on the server the created file. You can provide the file name to be used.
To store the file you must specify the path
OverrideCell
To override any cell of the report you can implement the overrideCell method in you ExcelReport file with the following parameters:
- active_sheet
- current_row_no
- column_no
- value
- row_data
- column_name
Here you can override data, formatting, styling, alignment, etc. You can use any PhpSpreadsheet function available for the active sheet.
If you are not using a flat array with overrideCell you can pick the values that you want to appear in your cell. You can check the example here.
Config file
In the config file you can define
- excel file metadata
- namespace used for artisan command
- default theme
- default row height
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
- Lab36
- Cosmin Natea
- Andrea Molnar
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of excel-report with dependencies
illuminate/support Version ^5.7|^5.8|^6.0|^7.0|^8.0
phpoffice/phpspreadsheet Version ^1.5