Download the PHP package fastbolt/excel-writer without Composer
On this page you can find all versions of the php package fastbolt/excel-writer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fastbolt/excel-writer
More information about fastbolt/excel-writer
Files in fastbolt/excel-writer
Package excel-writer
Short Description A library for simple creation of excel-files
License MIT
Homepage https://github.com/fastbolt/ExcelWriter
Informations about the package excel-writer
Excel-Writer
This component is used for simple Excel-file generation in Symfony. You can pass either arrays of arrays, or arrays of entities to the generator class. If an entity references another entity as it's attribute, you will need to pass a callable to retrieve a specific value from that entity.
Installation
This package is available through Composer/Packagist:
Table size
The width of the table is set by the number of headers. The number of rows is set by the amount of data.
Columns
The order of columns is determined by the order of ColumnSetting instances given to ExcelGenerator::setColumns(). You need to define at least one column. The order of the content will not be changed if an array is passed to setContent().
If you are passing objects to setContent(), you will need to provide the name of the method that returns the values you want to display (like "getName").
You can also pass closures instead of the getter.
Style
Create an instance of the TableStyle class and set styles for the header row and the content. Pass the TableStyle to the generator.
To apply styles to individual columns, you can either pass the style arrays as the 5th (header style) and 6th (data style) argument to the constructor, or use the setter of the ColumnSettings class.
Autofilter
Autofilters can be set by calling the generator's setter method and passing a range:
Style presets
The following styles are presets, but can be overwritten in the TableStyle class
header
- borders: medium
- vertical-alignment: center
- horizontal-alignment: center
- color: FF366092 (blue)
Merging Cells
You can merge cells by passing an array of coordinate ranges to the generator 'mergeCells'-method. The content of the resulting cell will be centered. Calling the method multiple times will not overwrite previous merges.
Hints
- Floats have a preset decimal length of 2 (0.12), but that can be configured with the 4th parameter of the ColumnSetting constructor or its method setDecimalLength().
- PHP and Excel have problems working with large numbers. Pass numbers with 16+ digits as strings to string columns to display them correctly.