PHPackages                             pdfloresjdav/excelbundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. pdfloresjdav/excelbundle

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

pdfloresjdav/excelbundle
========================

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

02.6kPHP

Since Sep 11Pushed 6y agoCompare

[ Source](https://github.com/pdfloresjdav/excelbundle)[ Packagist](https://packagist.org/packages/pdfloresjdav/excelbundle)[ RSS](/packages/pdfloresjdav-excelbundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Symfony2 Excel bundle
=====================

[](#symfony2-excel-bundle)

[![Total Downloads](https://camo.githubusercontent.com/664026f1957d190ccbda6f5696da9000b97cf117d376150bcd11e16d8c2f1c10/68747470733a2f2f706f7365722e707567782e6f72672f6c69756767696f2f457863656c42756e646c652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/liuggio/ExcelBundle) [![Latest Stable Version](https://camo.githubusercontent.com/82b01663133dd13d1e8356926263311de29b89a43f2e0c642f05e0970ed38445/68747470733a2f2f706f7365722e707567782e6f72672f6c69756767696f2f457863656c42756e646c652f762f737461626c652e706e67)](https://packagist.org/packages/liuggio/ExcelBundle)

This bundle permits you to create an easily modifiable excel object. This is just a dependency injection that links

3 Objects:

- The container in this bundle,
- The StreamWrapper in the n3bStreamresponse
- A Writer.

You could create your own writer extending `n3b\Bundle\Util\HttpFoundation\StreamResponse\StreamWriterInterface` or you could use the great PHPExcel library. With PHPExcel you can create xls, ods, pdf and more.

You have to know that csv is faster so I encourage you to use the built-in function for csv: [http://it.php.net/manual-lookup.php?pattern=csv&amp;lang=en&amp;scope=quickref](http://it.php.net/manual-lookup.php?pattern=csv&lang=en&scope=quickref)

Migration
---------

[](#migration)

In order to follow the naming convention  all the liuggio namespaces are migrated to Liuggio.

This master is up-to-date to the symfony/symfony master actually on 2.1

INSTALLATION with COMPOSER
--------------------------

[](#installation-with-composer)

1 Add to composer.json to the `require` key

```
    "require" : {
        "liuggio/excelbundle": ">=1.0.4",
    }

```

2 Register the bundle in `app/AppKernel.php`

```
    $bundles = array(
        // ...
        new Liuggio\ExcelBundle\LiuggioExcelBundle(),
    );
```

INSTALLATION with deps file
---------------------------

[](#installation-with-deps-file)

1 Add to the following to your `deps` file, then run `php bin/vendors install`

```
[PHPExcel]
    git=http://github.com/PHPOffice/PHPExcel.git
    target=/phpexcel
    version=origin/master

[n3bStreamresponse]
    git=git://github.com/liuggio/Symfony2-StreamResponse.git
    target=n3b/src/n3b/Bundle/Util/HttpFoundation/StreamResponse

[LiuggioExcelBundle]
    git=https://github.com/liuggio/ExcelBundle.git
    target=/bundles/Liuggio/ExcelBundle
```

2 Register the namespaces and prefixes in `app/autoload.php`:

```
    $loader->registerNamespaces(array(
        // ...
        'n3b\\Bundle\\Util\\HttpFoundation\\StreamResponse' => __DIR__.'/../vendor/n3b/src',
        'Liuggio'          => __DIR__.'/../vendor/bundles',
    ));
    $loader->registerPrefixes(array(
        // ...
        'PHPExcel'         => __DIR__.'/../vendor/phpexcel/Classes',
    ));
```

3 Enable the bundle in `app/AppKernel.php`

```
    $bundles = array(
        // ...
        new Liuggio\ExcelBundle\LiuggioExcelBundle(),
    );
```

AVAILABLE SERVICES
------------------

[](#available-services)

If you want to write

```
   // create MS Excel5
   $excelService = $this->get('xls.service_xls5');
   // create pdf
   $this->get('xls.service_pdf');
   // create MS Excel 2007
   $this->get('xls.service_xls2007');
```

If you want to read xls

```
    $excelObj = $this->get('xls.load_xls5')->load($filename);
```

USAGE
-----

[](#usage)

Create a controller in your bundle

```
namespace YOURNAME\YOURBUNDLE\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
{

    public function indexAction($name)
    {
        // ask the service for a Excel5
        $excelService = $this->get('xls.service_xls5');
        // or $this->get('xls.service_pdf');
        // or create your own is easy just modify services.yml

        // create the object see http://phpexcel.codeplex.com documentation
        $excelService->excelObj->getProperties()->setCreator("Maarten Balliauw")
                            ->setLastModifiedBy("Maarten Balliauw")
                            ->setTitle("Office 2005 XLSX Test Document")
                            ->setSubject("Office 2005 XLSX Test Document")
                            ->setDescription("Test document for Office 2005 XLSX, generated using PHP classes.")
                            ->setKeywords("office 2005 openxml php")
                            ->setCategory("Test result file");
        $excelService->excelObj->setActiveSheetIndex(0)
                    ->setCellValue('A1', 'Hello')
                    ->setCellValue('B2', 'world!');
        $excelService->excelObj->getActiveSheet()->setTitle('Simple');
        // Set active sheet index to the first sheet, so Excel opens this as the first sheet
        $excelService->excelObj->setActiveSheetIndex(0);

        //create the response
        $response = $excelService->getResponse();
        $response->headers->set('Content-Type', 'text/vnd.ms-excel; charset=utf-8');
        $response->headers->set('Content-Disposition', 'attachment;filename=stdream2.xls');

        // If you are using a https connection, you have to set those two headers and use sendHeaders() for compatibility with IE headers->set('Pragma', 'public');
        $response->headers->set('Cache-Control', 'maxage=1');

        return $response;
    }
}
```

With the right writer (e.g. PHPExcel\_Writer\_Excel5) you could also write the output to a file:

```

	public function indexAction($name)
    {
        $excelService = $this->get('xls.service_xls5');

        //...create php excel object

        $excelService->getStreamWriter()->write( $filename );
    }
```

ADVANCED USE
------------

[](#advanced-use)

If you need to, see and modify `Liuggio\ExcelBundle\Resources\config\services.yml`

Contributors
------------

[](#contributors)

@pivasyk

@dirkbl

@DerStoffel

@artturi

@isqad88

@mazenovi

@jochenhilgers

@Squazic

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ba4aea43b38cf2ce410e99e1bb6c19967a52438c7bf1ceb15b5e7f890625eedc?d=identicon)[pdfloresj](/maintainers/pdfloresj)

---

Top Contributors

[![pdfloresjdav](https://avatars.githubusercontent.com/u/31741062?v=4)](https://github.com/pdfloresjdav "pdfloresjdav (4 commits)")

### Embed Badge

![Health badge](/badges/pdfloresjdav-excelbundle/health.svg)

```
[![Health](https://phpackages.com/badges/pdfloresjdav-excelbundle/health.svg)](https://phpackages.com/packages/pdfloresjdav-excelbundle)
```

###  Alternatives

[phpoffice/phpspreadsheet

PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine

13.9k293.5M1.2k](/packages/phpoffice-phpspreadsheet)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/packages/spatie-browsershot)[smalot/pdfparser

Pdf parser library. Can read and extract information from pdf file.

2.7k34.5M216](/packages/smalot-pdfparser)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.1k57.6M130](/packages/openspout-openspout)[keboola/csv

Keboola CSV reader and writer

1451.8M21](/packages/keboola-csv)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
