PHPackages                             iteracode/excel - 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. iteracode/excel

ActiveCakephp-plugin[PDF &amp; Document Generation](/categories/documents)

iteracode/excel
===============

Excel plugin for CakePHP 3

0.1.1(8y ago)0538MITPHPPHP &gt;=5.4

Since Jul 26Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Iteracode/excel)[ Packagist](https://packagist.org/packages/iteracode/excel)[ Docs](https://github.com/cewi/excel)[ RSS](/packages/iteracode-excel/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (4)Versions (6)Used By (0)

Iteracode/Excel plugin for CakePHP
==================================

[](#iteracodeexcel-plugin-for-cakephp)

The plugin is based on the work of \[dakota\] () and uses [PHPExcel](https://github.com/PHPOffice/PHPExcel) for the excel-related functionality.

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

[](#installation)

You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).

The recommended way to install composer packages is:

add

```
"repositories": [
         {
            "type": "vcs",
            "url": "https://github.com/Iteracode/excel"
        }
    ]

```

to your composer.json because this package is not on packagist. Then in your console:

```
composer require Iteracode/Excel:dev-master

```

should fetch the plugin.

Load the Plugin in your bootstrap.php as ususal:

```
	Plugin::load('Iteracode/Excel', ['bootstrap' => true, 'routes'=>true]);

```

RequestHandler Component is configured by the Plugin's bootstrap file. If not you could do this this in your controller's initialize method, e.g.:

```
	public function initialize()
		{
        		parent::initialize();
        		$this->loadComponent('RequestHandler', [
            			'viewClassMap' => ['xlsx' => 'Iteracode/Excel.Excel']
        ]);
        	}

```

Be careful: RequestHandlerComponent is already loaded in your AppController by default. Adapt the settings to your needs.

You need to set up parsing for the xlsx extension. Add the following to your config/routes.php file before any route or scope definition:

```
Router::extensions('xlsx');

```

or you can add within a scope:

```
$routes->setExtensions(['xlsx']);

```

(Setting this in the plugin's config/routes.php file is currently broken. So you do have to provide the code in the application's config/routes.php file)

You further have to provide a layout for the generated Excel-Files. Add a folder xlsx in src/Template/Layout/ subdirectory and within that folder a file named default.ctp with this minimum content:

```

```

You can create Excel Workbooks from views. This works like in [dakotas](https://github.com/dakota/CakeExcel) plugin. Look there for docs. Additions:

1. ExcelHelper
--------------

[](#1-excelhelper)

Has a Method 'addworksheet' which takes a ResultSet, a Entity, a Collection of Entities or an Array of Data and creates a worksheet from the data. Properties of the Entities, or the keys of the first record in the array are set as column-headers in first row of the generated worksheet. Be careful if you use non-standard column-types. The Helper actually works only with strings, numbers and dates.

Register xlsx-Extension in config/routes.php file before the routes that should be affected:

```
    Router::extensions(['xlsx']);

```

Example (assumed you have an article model and controller with the usual index-action)

Include the helper in ArticlesController:

```
   public $helpers = ['Iteracode/Excel.Excel'];

```

add a Folder 'xlsx' in Template/Articles and create the file 'index.ctp' in this Folder. Include this snippet of code to get an excel-file with a single worksheet called 'Articles':

```
    $this->Excel->addWorksheet($articles, 'Articles');

```

create the link to generate the file somewhere in your app:

```

```

done.

2. ImportComponent
------------------

[](#2-importcomponent)

Takes a excel workbook, extracts a single worksheet with data (e.g. generated with the helper) and generates an array with data ready for building entities. First row must contain names of properties/database columns.

Include the Import-Component in the controller:

```
 public function initialize()
 {
    parent::initialize();
    $this->loadComponent('Iteracode/Excel.Import');
 }

```

than you can use the method

```
 prepareEntityData($file = null, array $options = [])

```

E.g. if you've uploaded a file:

```
 move_uploaded_file($this->gerRequest()->getData('file.tmp_name'), TMP . DS . $this->getRequest()->getData('file.name'));
 $data = $this->Import->prepareEntityData(TMP . $this->getRequest()->getData('file.name'));

```

and you'll get an array with data like you would get from the form-helper. You then can generate and save entities in the Controller:

```
 $entities = $table->newEntities($data);
 foreach ($entities as $entity) {
       $table->save($entity, ['checkExisting' => false])
 }

```

if your table is not empty and you don't want to replace records in the database, set `'append'=>true` in the $options array:

```
$data = $this->Import->prepareEntityData($file, ['append'=> true]);

```

If there are more than one worksheets in the file you can supply the name or index of the Worksheet to use in the $options array, e.g.:

```
$data = $this->Import->prepareEntityData($file, ['worksheet'=> 0]);

```

or

```
$data = $this->Import->prepareEntityData($file, ['worksheet'=> 'Articles']);

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.2% 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 ~88 days

Total

4

Last Release

2949d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17047944?v=4)[Bonjour Iteracode](/maintainers/Iteracode)[@Iteracode](https://github.com/Iteracode)

---

Top Contributors

[![cewi](https://avatars.githubusercontent.com/u/1643900?v=4)](https://github.com/cewi "cewi (70 commits)")[![Casmo](https://avatars.githubusercontent.com/u/385764?v=4)](https://github.com/Casmo "Casmo (1 commits)")[![dewwwald](https://avatars.githubusercontent.com/u/6582424?v=4)](https://github.com/dewwwald "dewwwald (1 commits)")

---

Tags

cakephpexcel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/iteracode-excel/health.svg)

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

###  Alternatives

[liuggio/excelbundle

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

3776.4M10](/packages/liuggio-excelbundle)[dakota/cake-excel

CakePHP excel generator

2324.9k](/packages/dakota-cake-excel)[wisembly/excelant

72158.3k](/packages/wisembly-excelant)[arogachev/yii2-excel

ActiveRecord import and export based on PHPExcel for Yii 2 framework

6480.3k1](/packages/arogachev-yii2-excel)[satthi/csv-combine-plugin-for-cakephp

CakePHP CsvCombine

1686.0k](/packages/satthi-csv-combine-plugin-for-cakephp)[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)
