PHPackages                             robotusers/cakephp-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. robotusers/cakephp-excel

ActiveCakephp-plugin[Utility &amp; Helpers](/categories/utility)

robotusers/cakephp-excel
========================

Robotusers CakePHP Excel plugin

0.7.0(2y ago)2312.8k↑561.5%10[1 issues](https://github.com/robotusers/cakephp-excel/issues)[1 PRs](https://github.com/robotusers/cakephp-excel/pulls)MITPHPPHP ^7.2|^8.0

Since Mar 22Pushed 2y ago6 watchersCompare

[ Source](https://github.com/robotusers/cakephp-excel)[ Packagist](https://packagist.org/packages/robotusers/cakephp-excel)[ Docs](https://github.com/robotusers/cakephp-excel)[ RSS](/packages/robotusers-cakephp-excel/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (7)Versions (11)Used By (0)

CakePHP Excel plugin
====================

[](#cakephp-excel-plugin)

[![Latest Stable Version](https://camo.githubusercontent.com/0358f6376ac9e2075c76ae4e4d3739619415c001dbb8a23fe57ab41ef59f890b/68747470733a2f2f706f7365722e707567782e6f72672f726f626f7475736572732f63616b657068702d657863656c2f762f737461626c65)](https://packagist.org/packages/robotusers/cakephp-excel)[![Total Downloads](https://camo.githubusercontent.com/16e3af62e08da02701cd52c724bf1ebc1030b205af2d2ee4a19430893173cc3f/68747470733a2f2f706f7365722e707567782e6f72672f726f626f7475736572732f63616b657068702d657863656c2f646f776e6c6f616473)](https://packagist.org/packages/robotusers/cakephp-excel)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)[![Build Status](https://camo.githubusercontent.com/250ea8f4d6aa48c70d31c64e604d70b77d401ce95018c13758f1c7c06623fcb7/68747470733a2f2f7472617669732d63692e6f72672f726f626f7475736572732f63616b657068702d657863656c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/robotusers/cakephp-excel)[![codecov](https://camo.githubusercontent.com/419245d87e3ce247c2832945a0e3d8ba935534da7166f417d809ebbdec305005/68747470733a2f2f636f6465636f762e696f2f67682f726f626f7475736572732f63616b657068702d657863656c2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/robotusers/cakephp-excel)

CakePHP Excel plugin allows for spreadsheet files manipulation with the power of CakePHP ORM. This plugin is build using [PHPSpreadsheet](https://github.com/PHPOffice/PHPSpreadsheet) library and can work with multiple types of spreadsheet files (excel, csv etc).

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

[](#installation)

```
composer require robotusers/cakephp-excel

```

```
//Application.php

public function bootstrap()
{
    ...
    $this->addPlugin('Robotusers/Excel');
}
```

Using the plugin
----------------

[](#using-the-plugin)

Excel plugin lets you manipulate spreadsheet files multiple ways. The simplest use case is to load your spreadhseet data into CakePHP ORM table.

For example we are loading an excel file that contains some record data.

ABC1Led ZeppelinLed Zeppelin II19692Deep PurpleMachine Head19723Pink FloydWish You Were Here1975```
use Robotusers/Excel/Registry;

$registry = Registry::instance();
$table = $registry->get('path/to/records.xlsx', 'Albums');
```

Spreadsheet data is now loaded into CakePHP ORM table.

```
$row = $table->find()->first()->toArray();

//this is how a simple row looks like:
[
    '_row' => 1,
    'A' => 'Led Zeppelin',
    'B' => 'Led Zeppelin II',
    'C' => '1969'
]
```

Each column is represented as a property. Values are `string` by default.

You may also map columns to custom properties and types.

```
use Robotusers/Excel/Registry;

$registry = Registry::instance();
$table = $registry->get('path/to/records.xlsx', 'Albums', [
    'primaryKey' => 'id',
    'columnMap' => [
        'A' => 'band',
        'B' => 'album',
        'C' => 'year'
    ],
    'columnTypeMap' => [
        'C' => 'date'
    ]
]);
```

Spreadsheet data is now loaded into CakePHP ORM with custom properties and types.

```
$row = $table->find()->first()->toArray();

//this is how a simple row looks like:
[
    'id' => 1,
    'band' => 'Led Zeppelin',
    'album' => 'Led Zeppelin II',
    'year' => object(Cake\I18n\Date) {
        'time' => '1969-01-01T00:00:00+00:00',
        'timezone' => 'UTC'
    }
]
```

You may want to manipulate some data and write it back to excel file. This is also possible.

```
$row = $table->newEntity([
    'band' => 'Genesis',
    'album' => 'Selling England by the Pound',
    'year' => '1973'
]);
$table->save($row);
```

Now the new record is saved, but excel file has not been updated yet. You have to call `writeSpreadsheet()` method:

```
$table->writeSpreadsheet();
```

You may also want to read or write only some of the rows and columns.

```
use Robotusers/Excel/Registry;

$table = $registry->get('path/to/records.xlsx', 'Albums', [
    'startRow' => 2,
    'endRow' => 3,
    'startColumn' => 'B',
    'endColumn' => 'B'
]);

$row = $table->find()->first()->toArray();

//this is how a simple row looks like:
[
    '_row' => 1,
    'B' => 'Machine Head'
]
```

Note that `_row` does not match the real row index. To keep original row indexes you must use `keepOriginalRows` option.

```
use Robotusers/Excel/Registry;

$table = $registry->get('path/to/records.xlsx', 'Albums', [
    'startRow' => 2,
    'endRow' => 3,
    'startColumn' => 'B',
    'endColumn' => 'B',
    'keepOriginalRows' => true
]);

$row = $table->find()->first()->toArray();

//this is how a simple row looks like:
[
    '_row' => 2,
    'B' => 'Machine Head'
]
```

The same principle applies to writing to a file. If you delete the second row it won't become empty in result excel file when `keepOriginalRows` is `false`. You have to set this option to `true` if you want to keep rows consistency across the table and the file.

Behavior
--------

[](#behavior)

This plugin provides a behavior which could be added to any table.

```
//AlbumsTable.php

public function initialize()
{
    $this->addBehavior('Robotusers/Excel.Excel', [
        'columnMap' => [
            'A' => 'band',
            'B' => 'album',
            'C' => 'year'
        ]
    ]);
}
```

If you want to load data into your table you have to set a worksheet instance.

```
use Cake\Filesystem\File;

$file = new File('path/to/file.xls');
$spreadsheet = $table->getManager()->getSpreadsheet($file); // \PhpOffice\PhpSpreadsheet\Spreadsheet instance
$worksheet = $spreadsheet->getActiveSheet(); // \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet instance

$table->setWorksheet($worksheet)->readSpreadsheet();
```

Now your table is populated with excel data.

If you want to write your data back to excel file you have to set a file.

```
$table->setFile($file)->writeSpreadsheet();
```

Working with different tables
-----------------------------

[](#working-with-different-tables)

It is also possible to load data into any table.

```
use Robotusers\Excel\Excel\Manager;

$table = TableRegistry::get('SomeTable');
$manager = new Manager();

$file = new File('file.xlsx');
$spreadsheet = $manager->getSpreadsheet($file);
$worksheet = $spreadsheet->getActiveSheet();

$manager->read($worksheet, $table, [
    'columnMap' => [
        'A' => 'band',
        'B' => 'album',
        'C' => 'year'
    ]
]);

//manipulate your data...

//here you have to tell where properties should be placed
$manager->write($table, $worksheet, [
    'propertyMap' => [
        'band' => 'A',
        'album' => 'B',
        'year' => 'C'
    ]
]);
//to actually save the file you have to call save()
$writer = $manager->save($spreadsheet, $file);
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~279 days

Recently: every ~609 days

Total

10

Last Release

876d ago

PHP version history (3 changes)0.1.0PHP &gt;=5.5

0.6.0PHP &gt;=5.6

0.7.0PHP ^7.2|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7437773?v=4)[Robert Pustułka](/maintainers/robertpustulka)[@robertpustulka](https://github.com/robertpustulka)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

54681.3k18](/packages/solspace-craft-freeform)[pimcore/data-importer

Adds a comprehensive import functionality to Pimcore Datahub

46855.5k5](/packages/pimcore-data-importer)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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