iter8 / builder
A wrapper for the PHP Excel library to help you quickly build reports
Installs: 14 382
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 3
Requires
- php: >=7.1
- box/spout: ^2.7
- phpoffice/phpspreadsheet: ~1.2
- webmozart/assert: ^1.3
Requires (Dev)
- phpunit/phpunit: ^7.0
- silex/silex: ^2.0
- symfony/var-dumper: ^4.1
This package is auto-updated.
Last update: 2025-03-29 00:40:27 UTC
README
A wrapper for the PhpSpreadsheet and Spout libraries to help you quickly build Excel reports.
Requirements
- Silex ~2.x
Example Usage
$app['builder.default'] = 'spout'; // or 'phpspreadsheet' $app['builder.cache_dir'] = '/var/cache'; $app->register(new BuilderServiceProvider()); // --- OR --- $app->register( new BuilderServiceProvider(), [ 'builder.default' => 'phpspreadsheet', 'builder.cache_dir' => '/var/cache', ] );
$builder = $app['builder']; $reportArray = [ 'headers' => [ 'Column 1', 'Column B', ], 'rows' => [ [ 'Some Data', 'Some Other Data', ], [ 'Some Data 2', 'Some Other Data 2', ], ], ]; $builder->setSheets([$reportArray]); $builder->setCreator('App Name'); $builder->setTitle('My Spreadsheet'); $builder->setSheetTitles(['Sheet 1']); $builder->setDescription('Spreadsheet that contains some data'); $builder->setFilename('App_Name_Spreadsheet_' . $startDate->format('d_m_Y')); // use generate() to output headers and force file download. $builder->generate(); // use generateExcel() to create the file. $builder->generateExcel();
Both Builders are available under the $app['builders']
key, but $app['builder']
will be the default builder you specify.
PhpSpreadsheet
Accessible via $app['builders']['phpspreadsheet']
.
Spout
Accessible via $app['builders']['spout']
.
Feature Parity
Feature | PhpSpreadsheet | Spout |
---|---|---|
Cell Alignment | Yes | No |
Auto-sizing Columns | Yes | No |
Custom Column Widths | Yes | No |
Document Properties | Yes | No |
Header Styling | Yes | Yes |
Multiple Sheets | Yes | Yes |
Development
Todo
- Allow both caching when building a report as well as short term or perm-caching to a configured location.
Testing
Minimal tests can be performed with PHPUnit.
Unit Tests
composer tests
or ./vendor/bin/phpunit
Code Coverage
composer coverage
These will be available in ./builder_coverage
.