PHPackages                             glider88/relative-coordinates - 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. glider88/relative-coordinates

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

glider88/relative-coordinates
=============================

Plugin for PhpSpreadsheet, add relative coordinates transformer

1.0.1(5mo ago)03MITPHPPHP ^8.1

Since Dec 7Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/Glider88/relative-coordinates)[ Packagist](https://packagist.org/packages/glider88/relative-coordinates)[ Docs](https://github.com/Glider88/relative-coordinates)[ RSS](/packages/glider88-relative-coordinates/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Relative Coordinates
====================

[](#relative-coordinates)

Abstraction for PhpSpreadsheet, add relative coordinate transformer.

Installation:

```
composer require glider88/relative-coordinates
```

Start:

```
bin/re  # first run
```

```
bin/up  # start app
```

```
bin/unit # run tests
```

The core idea is to define area with relative sub coordinates. This allows you to define a table template and use it in many places in an Excel document. Also, you can easily add, remove, swap columns without affecting the rest of the sheet.

```
$coordT = RelativeCoordinates::new('B3', ['one', 'two', 'three']);
```

If you need formulas in Excel:

```
$dataT = new RelativeData($coordT);
```

Might be useful, class for easy selection of columns and rows:

```
$positional = new PositionalCoordinates($columns, $height);

$firstColumn = $positional->relativeColumn(1);
$lastRow = $positional->relativeRow(-1);
```

Table template:

```
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use Glider88\RelativeCoordinates\Relative\RelativeCoordinates;
use Glider88\RelativeCoordinates\Relative\RelativeData;
use PhpOffice\PhpSpreadsheet\Style\Fill;

$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();

$start = 'B3';
$avg = static fn(string $color) => "=AVERAGE({{{$color}2:{$color}4}})";
$data = [
    ['Color', 'Red', 'Green', 'Blue'],
    ['yellow',  255, 255,   0],
    ['cyan',      0, 255, 255],
    ['magenta', 255,   0, 255],
    ['Average color', $avg('red'), $avg('green'), $avg('blue')]
];

$coordT = RelativeCoordinates::new($start, ['color', 'red', 'green', 'blue']);
$dataT = new RelativeData($coordT);

// table styles
$worksheet
    ->getStyle($coordT->absolute('color1:blue1'))
    ->getFont()
    ->setBold(true);

$worksheet
    ->getStyle($coordT->absolute('color1:blue1'))
    ->getFill()
    ->setFillType(Fill::FILL_SOLID)
    ->getStartColor()
    ->setARGB('509965');

$worksheet
    ->getStyle($coordT->absolute('color5:blue5'))
    ->getFill()
    ->setFillType(Fill::FILL_SOLID)
    ->getStartColor()
    ->setARGB('81a8f0');
// end styles

$worksheet->fromArray($dataT->absolute($data), null, $start);

$writer = IOFactory::createWriter($spreadsheet, 'Xls');
$writer->save('table.xls');
```

More complex example: `example/Table.php`

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance72

Regular maintenance activity

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

161d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7103e36446ad2fc58a3da730afd7d0c5a0b89b01a231dbd537832030bd8cadd7?d=identicon)[Glider88](/maintainers/Glider88)

---

Top Contributors

[![Glider88](https://avatars.githubusercontent.com/u/1173406?v=4)](https://github.com/Glider88 "Glider88 (1 commits)")

---

Tags

phpexcelxlsrelativephpspreadsheet

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/glider88-relative-coordinates/health.svg)

```
[![Health](https://phpackages.com/badges/glider88-relative-coordinates/health.svg)](https://phpackages.com/packages/glider88-relative-coordinates)
```

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[yidas/phpspreadsheet-helper

PHP Excel Helper - Write and read Spreadsheet with easy way based on PhpSpreadsheet

383144.5k3](/packages/yidas-phpspreadsheet-helper)

PHPackages © 2026

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