PHPackages                             harborcompliance/cakephp-xlsxview - 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. harborcompliance/cakephp-xlsxview

ActiveCakephp-plugin

harborcompliance/cakephp-xlsxview
=================================

An XLSX View class for CakePHP

111.8k↓20.8%1PHP

Since Feb 3Pushed 4y ago4 watchersCompare

[ Source](https://github.com/HarborCompliance/cakephp-xlsxview)[ Packagist](https://packagist.org/packages/harborcompliance/cakephp-xlsxview)[ RSS](/packages/harborcompliance-cakephp-xlsxview/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

XlsxView plugin for CakePHP
===========================

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

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

[](#installation)

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

The recommended way to install composer packages is:

```
composer require harborcompliance/cakephp-xlsxview
```

### Enable plugin

[](#enable-plugin)

Load the plugin by running command

```
bin/cake plugin load XlsxView
```

Usage
-----

[](#usage)

A basic example writing an array to the xlsx file.

```
public function export()
{
    $data = [
        ['id' => 1, 'name' => 'Alex', 'email' => 'alex@example.com'],
        ['id' => 2, 'name' => 'Jason', 'email' => 'jason@example.com'],
    ];

    $this->set(compact('data'));
    $this->viewBuilder()
        ->setClassName('XlsxView.Xlsx')
        ->setOption('serialize', 'data');
}
```

You may specify an optional header that will be the first row in your xlsx file.

```
public function export()
{
    $data = [
        ['id' => 1, 'name' => 'Alex', 'email' => 'alex@example.com'],
        ['id' => 2, 'name' => 'Jason', 'email' => 'jason@example.com'],
    ];

    $header = ['ID', 'Name', 'Email'];

    $this->set(compact('data'));
    $this->viewBuilder()
        ->setClassName('XlsxView.Xlsx')
        ->setOptions([
            'serialize' => 'data',
            'header' => $header,
        ]);
}
```

### Automatic View Class Switching

[](#automatic-view-class-switching)

You can use the router's extension parsing feature and the `RequestHandlerComponent` to automatically use the XlsxView class.

Enable `xlsx` extension parsing for all routes using `Router::extensions('xlsx')` in your app's `routes.php` or using `$routes->addExtensions()` within the required scope.

```
// UsersController.php

// In your controller's initialize() method:
$this->loadComponent('RequestHandler');

// Controller action
public function index()
{
    $users = $this->Users->find();
    $this->set(compact('users'));

    if ($this->request->is('xlsx')) {
        $this->viewBuilder()->setOptions([
            'serialize' => 'users',
            'header' => $header,
        ]);
    }
}
```

With the above controller you can now access `/users.xlsx` or use the `Accept` header `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet` to get the data as an xlsx file and use `/users` to get normal HTML page.

### Setting the Downloaded File Name

[](#setting-the-downloaded-file-name)

By default, the downloaded file will be named after the final portion of the url. To explicitly set the filename use the `Response::withDownload()` method.

```
public function export()
{
    // ...

    $this->response = $this->response->withDownload('users.xlsx');
}
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 Bus Factor1

Top contributor holds 60% 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/a1a0526aa8ba0c139519ce84c2a6b6402106cb98d36bc8390916b88ff9abd223?d=identicon)[harborcompliance](/maintainers/harborcompliance)

---

Top Contributors

[![amayer-hc](https://avatars.githubusercontent.com/u/63778085?v=4)](https://github.com/amayer-hc "amayer-hc (3 commits)")[![howe-jm](https://avatars.githubusercontent.com/u/68206442?v=4)](https://github.com/howe-jm "howe-jm (2 commits)")

### Embed Badge

![Health badge](/badges/harborcompliance-cakephp-xlsxview/health.svg)

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

PHPackages © 2026

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