PHPackages                             arodiss/xls-bundle - 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. arodiss/xls-bundle

ActiveSymfony-bundle[PDF &amp; Document Generation](/categories/documents)

arodiss/xls-bundle
==================

Excel files manipulation for Symfony2

v0.6.0(8y ago)5108.5k8MITPHPPHP &gt;=5.3.2

Since Oct 22Pushed 7y ago4 watchersCompare

[ Source](https://github.com/arodiss/XlsBundle)[ Packagist](https://packagist.org/packages/arodiss/xls-bundle)[ Docs](https://github.com/arodiss/xls-bundle)[ RSS](/packages/arodiss-xls-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (23)Used By (0)

Xls Bundle
==========

[](#xls-bundle)

Trivia read and write of .xls files for Symfony2, built on top of the [PHPExcel](https://github.com/PHPOffice/PHPExcel/)

Installation
------------

[](#installation)

Via composer:

```
require: {
    ...
    "arodiss/xls-bundle": "*@stable"
}

```

Usage examples:
---------------

[](#usage-examples)

Read a small file
-----------------

[](#read-a-small-file)

```
$reader = $container->get("arodiss.xls.reader");
$content = $reader->readAll("/path/to/file.xls");
var_dump($content);
//array(2) =>
//    array(2) =>
//        0 => string(10) "First line"
//        1 => null
//    array(2) =>
//        0 => string(10) "Line number"
//        1 => int 2
```

Read a big file
---------------

[](#read-a-big-file)

Previous method can exhaust your memory if the file is big. However this is safe:

```
$reader = $container->get("arodiss.xls.reader");
$iterator = $reader->getReadIterator("/path/to/file.xls");
while($iterator->valid())
{
    var_dump($iterator->current());
    $iterator->next();
}
//same output format
```

Read even a bigger file
-----------------------

[](#read-even-a-bigger-file)

Sometime PHPOffice just can't provide reasonable performance. For this case bundle provides alternative reader which wraps python implementation. It is rudimentary in terms of functionality and especially interactions (like error handling), but performs faster, especially on large files. In order to use it, you have to install `openpyxl` (for xlsx) and xlrd (for xls) libraries, which you can easily do through [pip](https://pypi.python.org/pypi/pip) package manager

```
$reader = $container->get("arodiss.xls.reader.python");
$iterator = $reader->getReadIterator("/path/to/file.xls");
while($iterator->valid())
{
    var_dump($iterator->current());
    $iterator->next();
}
//same output format
```

Return XLS file from Symfony controller
---------------------------------------

[](#return-xls-file-from-symfony-controller)

```
$file = $container
    ->get("arodiss.xls.builder")
    ->buildXlsFromArray(array(
        array("row one field one", "row one field two"),
        array("row two field one")
    ))
;

//now $file is path to tmp file with data

$response = new Response();
$response->headers->set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
$response->headers->set("Content-Disposition", "attachment;filename=excelfile.xlsx");
$response->setContent(file_get_contents($file));
return $response;
```

Write in a file (recommended)
-----------------------------

[](#write-in-a-file-recommended)

```
$writer = $container->get("arodiss.xls.writer.buffered");
$writer->create("users.xls", array("name", "email")); //second argument represents first row

foreach ($userProvider->getUsers() as $user) {
    $writer->appendRow("users.xls", array($user->getName(), $user->getEmail()));
}
$writer->flush();
```

Write in a file (not recommended)
---------------------------------

[](#write-in-a-file-not-recommended)

Write operations for xls format are extremely expensive, so previous example uses BufferedWriter which stores your data in buffer and writes in file only once, when flushing the buffer. If for some reason this is not what you want to achieve, you may use service `xls.writer` in stead of `xls.writer.buffered`.

Formats supported
-----------------

[](#formats-supported)

Files are always written in Excel2007 (.xlsx) format. Read operations, however, MAY work also for other formats supported by PHPExcel (Excel5, Office Open XML, SpreadsheetML, OASIS, CSV, Gnumeric, SYLK) however there is no guarantee for it.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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.

###  Release Activity

Cadence

Every ~72 days

Recently: every ~127 days

Total

22

Last Release

3065d ago

### Community

Maintainers

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

---

Top Contributors

[![arodiss](https://avatars.githubusercontent.com/u/925376?v=4)](https://github.com/arodiss "arodiss (10 commits)")[![reggin](https://avatars.githubusercontent.com/u/1917390?v=4)](https://github.com/reggin "reggin (2 commits)")[![girayk](https://avatars.githubusercontent.com/u/7294430?v=4)](https://github.com/girayk "girayk (1 commits)")[![robholmes](https://avatars.githubusercontent.com/u/206717?v=4)](https://github.com/robholmes "robholmes (1 commits)")[![Wampirusy](https://avatars.githubusercontent.com/u/9334908?v=4)](https://github.com/Wampirusy "Wampirusy (1 commits)")

---

Tags

bundleexcelphpphpexcelsymfonysymfony-bundlexlsxlsxexportexcelxlsimport

### Embed Badge

![Health badge](/badges/arodiss-xls-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/arodiss-xls-bundle/health.svg)](https://phpackages.com/packages/arodiss-xls-bundle)
```

###  Alternatives

[moonlandsoft/yii2-phpexcel

Exporting PHP to Excel or Importing Excel to PHP

1491.1M16](/packages/moonlandsoft-yii2-phpexcel)[arogachev/yii2-excel

ActiveRecord import and export based on PHPExcel for Yii 2 framework

6480.3k1](/packages/arogachev-yii2-excel)[jgrygierek/batch-entity-import-bundle

Importing entities with preview and edit features for Symfony.

101.1M1](/packages/jgrygierek-batch-entity-import-bundle)[jgrygierek/sonata-batch-entity-import-bundle

Importing entities with preview and edit features for Sonata Admin.

10951.2k](/packages/jgrygierek-sonata-batch-entity-import-bundle)[phpnt/yii2-export

Yii2 It saves data in xls, csv, word, html, pdf files.

158.9k](/packages/phpnt-yii2-export)

PHPackages © 2026

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