PHPackages                             aklump/loft\_data\_grids - 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. aklump/loft\_data\_grids

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

aklump/loft\_data\_grids
========================

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

0.7.1(1y ago)1119.6k5BSD-3-ClausePHPPHP &gt;=7.1 || &lt;=8.1

Since Jul 14Pushed 1y ago2 watchersCompare

[ Source](https://github.com/aklump/loft_data_grids)[ Packagist](https://packagist.org/packages/aklump/loft_data_grids)[ Docs](http://www.intheloftstudios.com/packages/php/loft_data_grids)[ RSS](/packages/aklump-loft-data-grids/feed)WikiDiscussions master Synced 1mo ago

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

Loft Data Grids
===============

[](#loft-data-grids)

[![](https://camo.githubusercontent.com/6d1b9bb08e35535df606fda96a76691211d32256d56af26b84b17c7db7b879d1/68747470733a2f2f62616467656e2e6e65742f7374617469632f7374617475732f646570726563617465642f726564)](https://camo.githubusercontent.com/6d1b9bb08e35535df606fda96a76691211d32256d56af26b84b17c7db7b879d1/68747470733a2f2f62616467656e2e6e65742f7374617469632f7374617475732f646570726563617465642f726564) [![Packagist link](https://camo.githubusercontent.com/288d5752b4574a0e1462f3ef137d1c76a1864d881a3be396abaeda71b760d6f4/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f6e616d652f616b6c756d702f6c6f66745f646174615f6772696473)](https://packagist.org/packages/aklump/loft_data_grids) [![](https://camo.githubusercontent.com/5931310bd7cdaa627ccddf0ae2238376816473ff71077ac7a8ce719615c4f473/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f616b6c756d702f6c6f66745f646174615f6772696473)](https://camo.githubusercontent.com/5931310bd7cdaa627ccddf0ae2238376816473ff71077ac7a8ce719615c4f473/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f616b6c756d702f6c6f66745f646174615f6772696473) [![](https://camo.githubusercontent.com/4d8221b06936a85571120cc8e15edc794b306a20c1dfae062482a9aac2e0db16/68747470733a2f2f62616467656e2e6e65742f6769746875622f6c6963656e73652f616b6c756d702f646f6d2d74657374696e672d73656c6563746f7273)](https://camo.githubusercontent.com/4d8221b06936a85571120cc8e15edc794b306a20c1dfae062482a9aac2e0db16/68747470733a2f2f62616467656e2e6e65742f6769746875622f6c6963656e73652f616b6c756d702f646f6d2d74657374696e672d73656c6563746f7273)

> There will be no new features added to this project. I suggest using the [Symfony Serializer Component](https://symfony.com/doc/current/components/serializer.html) instead for similar functionality. The project will not receive ongoing support.

Summary
-------

[](#summary)

This package is a PHP object-oriented solution for modelling data in two (rows + columns) or three dimensions (rows + columns + pages). It can be thought of like a spreadsheet.

It allows a single data class `ExportData` to be used to organize your data in a grid, with various output styles `Exporter` so you can easily get a `.csv` file or a `.xlsx` file, among many others.

See the code for more documentation.

Install with Composer
---------------------

[](#install-with-composer)

1. Require this package:

    ```
    composer require aklump/loft_data_grids:^0.7

    ```

Usage
-----

[](#usage)

Let's build a two-layer data grid. (Layers are called *pages*.) The first page will contain names and ages of three people. The second page will contain vehicle information. It can be pictured in two tables:

*Page 0*

NameAgeAdam39Brandon37Charlie7*Page 1*

ColorMakeBlackHondaWhiteBMW### In Code

[](#in-code)

```
$data_grid = new \AKlump\LoftDataGrids\ExportData();

// By default we're on page 0, row 0.
$data_grid->add('Name', 'Adam')->add('Age', 39)->next();
$data_grid->add('Name', 'Brandon')->add('Age', 37)->next();
$data_grid->add('Name', 'Charlie')->add('Age', 7)->next();

// Switch to page 1; we'll be placed on row 0.
$data_grid->setPage(1);
$data_grid->add('Color', 'Black')->add('Make', 'Honda')->next();
$data_grid->add('Color', 'White')->add('Make', 'BMW')->next();
```

### Accessing data from the object

[](#accessing-data-from-the-object)

Think of *pointer* as a row in a table.

```
$value = $data_grid->setPage(0)->setPointer(0)->getValue('Name') // $value === 'Adam'
$value = $data_grid->getValue('Name') // $value === 'Adam'
$value = $data_grid->setPointer(2)->getValue('Name') // $value === 'Charlie'
$value = $data_grid->setPointer(0)->get() // $value === array('Name' => 'Adam', 'Age' => 39)
$value = $data_grid->setPage(1)->setPointer(1)->getValue('Color') // $value === 'White'
```

### Exporting data to other formats

[](#exporting-data-to-other-formats)

We can export both pages in CSV like this:

```
$exporter = new \AKlump\LoftDataGrids\CSVExporter($data_grid);

$csv_string = $exporter->export();
// "Name","Age"
// "Adam","39"
// "Brandon","37"
// "Charlie","7"

$csv_string = $exporter->export(1);
// "Color","Make"
// "Black","Honda"
// "White","BMW"
```

Or to get it as JSON...

```
$exporter = new \AKlump\LoftDataGrids\JSONExporter($data_grid);
$json_string = $exporter->export();
```

*(This has been formatted for easier-reading; the actual JSON is minified.)*

```
[
  [
    {
      "Name": "Adam",
      "Age": 39
    },
    {
      "Name": "Brandon",
      "Age": 37
    },
    {
      "Name": "Charlie",
      "Age": 7
    }
  ],
  [
    {
      "Color": "Black",
      "Make": "Honda"
    },
    {
      "Color": "White",
      "Make": "BMW"
    }
  ]
]
```

Or any of the other exporter classes.

### Saving to File

[](#saving-to-file)

```
$exporter = new \AKlump\LoftDataGrids\XLSXExporter($data_grid, 'users');
$exporter->saveFile();
```

Exporters: objects as values
----------------------------

[](#exporters-objects-as-values)

- Exporters can handle objects if they implement the `objectHandler` method.
- Exporters can handle \\DateTime objects if they set a value for 'dateFormat'.

Testing
-------

[](#testing)

1. Run the PhpUnit tests with `./bin/run_unit_tests.sh`

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity75

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 ~77 days

Recently: every ~414 days

Total

54

Last Release

611d ago

PHP version history (5 changes)0.4.5PHP &gt;=5.3.0

0.4.20PHP &gt;=5.3.3

0.4.21PHP &gt;=5.3.5

0.5.0PHP &gt;=7.1

0.6.0PHP &gt;=7.1 || &lt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/79476f3b82f9c766433c7eb401cbcfc636cd5d5ccf2b2e6b50ea81d1de6c2730?d=identicon)[aklump](/maintainers/aklump)

---

Top Contributors

[![aklump](https://avatars.githubusercontent.com/u/425737?v=4)](https://github.com/aklump "aklump (229 commits)")

---

Tags

exportexcelcsvspreadsheet

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aklump-loft-data-grids/health.svg)

```
[![Health](https://phpackages.com/badges/aklump-loft-data-grids/health.svg)](https://phpackages.com/packages/aklump-loft-data-grids)
```

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M710](/packages/maatwebsite-excel)[kartik-v/yii2-export

A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.)

1623.1M35](/packages/kartik-v-yii2-export)

PHPackages © 2026

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