PHPackages                             zuko/flex2cell - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. zuko/flex2cell

ActiveLibrary[File &amp; Storage](/categories/file-storage)

zuko/flex2cell
==============

A flexible and efficient library for exporting data to Excel (XLS, XLSX) with support for mappings, formatters, and handling large datasets. Working with less dependencies, avoid future breaks &amp; conclusions.

1.0.6(1y ago)236MITPHPPHP &gt;=7.0 &lt;9CI passing

Since Oct 14Pushed 4mo agoCompare

[ Source](https://github.com/ultra-bugs/flex2cell)[ Packagist](https://packagist.org/packages/zuko/flex2cell)[ RSS](/packages/zuko-flex2cell/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

Flex2Cell
=========

[](#flex2cell)

**Flex2Cell** is a flexible and efficient PHP library for exporting data to Excel (XLS, XLSX) with support for headers, data mappings, formatters, and handling large datasets. It's dependent on the [PhpSpreadsheet](https://github.com/PHPOffice/PhpSpreadsheet) library.

Features
--------

[](#features)

- Export data to Excel in XLS or XLSX format using Microsoft's format.
- Supports data from collections, Eloquent models, or multi-dimensional arrays alternative to `Eloquent\Collection::toArray()` format.
- Allows custom column headers and mapping between data fields and Excel columns.
- Includes value formatting using transformers (e.g., formatting dates, transforming IDs to names).
- Supports hidden fields, meaning you can choose which fields should not appear in the export.
- Provides meta settings for the output file (e.g., author, title).
- Efficient memory usage when exporting large datasets.
- Supports partial exports with `replace` or `append` modes, allowing export in chunks.
- Custom column and row merging rules.

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

[](#installation)

To install the library, add it to your project via Composer:

```
composer require zuko/flex2cell
```

Usage
=====

[](#usage)

Simple Export Example
---------------------

[](#simple-export-example)

```
use Zuko\Flex2Cell\ExcelExporter;

$data = // your data here...

ExcelExporter::export($data, 'export.xlsx', [
    'headers' => ['#', 'Name', 'Product Group', 'Owner Name', 'Business Type', 'District', 'Commune'],
    'mapping' => [
        'id' => '#',
        'name' => 'Name',
        'product_group' => 'Product Group',
        'owner_name' => 'Owner Name',
        'owner_business_type' => 'Business Type',
        'district.name' => 'District',
        'village.name' => 'Commune',
    ],
    'formatters' => [
        'owner_business_type' => new CustomFormatter(),
        'district.name' => 'FullyQualifiedFormatterClassName',
    ],
    'columnMergeRules' => [
        ['start' => 'district.name', 'end' => 'village.name', 'label' => 'Address', 'shiftDown' => true]
    ],
    'rowMergeRules' => [
        'product_group', 'owner_name', 'owner_business_type'
    ]
]);
```

Fluent API Usage
----------------

[](#fluent-api-usage)

You can also use a fluent interface for more control:

```
use Zuko\Flex2Cell\ExcelExporter;

// custom formatter class
class BusinessTypeFormatter implements Zuko\Flex2Cell\Contracts\FormatterInterface
{
    public function formatValue($value)
    {
        return ucwords(str_replace('_', ' ', $value));
    }
}

$data = // your data here...

ExcelExporter::make()
             ->setData($data)
             ->setHeaders(['ID', 'Name', 'Product Area', 'Nursery Area', 'Category'])
             ->setMapping([
                 'id' => 'ID',
                 'name' => 'Name',
                 'product_area' => 'Product Area',
                 'nursery_area' => 'Nursery Area',
                 'category.name' => 'Category'
             ])
             ->setFormatters([
                 'category.name' => fn($value) => ucfirst($value),
                 'owner_business_type' => new CustomFormatter(),

             ])
             ->setColumnMergeRules([
                 ['start' => 'C', 'end' => 'D', 'label' => 'AREA']
             ])
             ->setRowMergeRules([
                 'E' => ['field' => 'category.name']
             ])
             ->export('export.xlsx');
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance60

Regular maintenance activity

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 89.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 ~3 days

Total

5

Last Release

568d ago

### Community

Maintainers

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

---

Top Contributors

[![tansautn](https://avatars.githubusercontent.com/u/6666271?v=4)](https://github.com/tansautn "tansautn (26 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

data-managementexcel-exporterlaravel-excellaravel-exportlaravel-package

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/zuko-flex2cell/health.svg)

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

PHPackages © 2026

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