A wrapper for the PHP Excel library to help you quickly build reports

4.0.4 2021-02-22 06:06 UTC


A wrapper for the PhpSpreadsheet and Spout libraries to help you quickly build Excel reports.


  • Silex ~2.x

Example Usage

$app['builder.default']   = 'spout'; // or 'phpspreadsheet'
$app['builder.cache_dir'] = '/var/cache';

$app->register(new BuilderServiceProvider());
// --- OR ---
    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->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.

// use generateExcel() to create the file.

Both Builders are available under the $app['builders'] key, but $app['builder'] will be the default builder you specify.


Accessible via $app['builders']['phpspreadsheet'].


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



  • Allow both caching when building a report as well as short term or perm-caching to a configured location.


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.