PHPackages                             jacketofseville/excel-pointer - 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. jacketofseville/excel-pointer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jacketofseville/excel-pointer
=============================

Excel pointer utility for XLS/XLSX navigation with PHP Spreadsheet packages.

00PHP

Since Oct 23Pushed 6mo agoCompare

[ Source](https://github.com/JacketOfSeville/excel-pointer)[ Packagist](https://packagist.org/packages/jacketofseville/excel-pointer)[ RSS](/packages/jacketofseville-excel-pointer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

excel-pointer
=============

[](#excel-pointer)

ExcelPointer is a PHP library for navigating Excel sheets, designed to work with PHPSpreadsheet or similar tools. It supports both XLS and XLSX boundaries and provides movement and coordinate tracking.

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

[](#installation)

Install via Composer:

```
composer require jacketofseville/excel-pointer
```

Basic Usage
-----------

[](#basic-usage)

```
require 'vendor/autoload.php';

$pointer = new ExcelPointer(); // Defaults to XLSX boundaries
$pointer->right();      // Move one column right
$pointer->down(5);      // Move five rows down
$pointer->left(2);      // Move two columns left
$pointer->up();         // Move one row up

// Get current coordinate as string (e.g., 'C5')
$coord = $pointer->coord();

// Get current coordinate as array
$coordArr = $pointer->coord('array'); // ['column' => 3, 'row' => 5]

// Get boundary (max column/row reached so far)
$boundary = $pointer->boundary();
```

More Examples
-------------

[](#more-examples)

### Using tab() for horizontal navigation

[](#using-tab-for-horizontal-navigation)

The `tab()` method returns the current coordinate and then moves the pointer one column to the right. This is useful for filling a row, like tabbing through cells in Excel:

```
$pointer = new ExcelPointer();
for ($i = 0; $i < 5; $i++) {
	$cell = $pointer->tab(); // Returns current cell, then moves right
	echo "Writing to $cell\n";
	// $sheet->setCellValue($cell, "Value $i");
}
```

### Filling a table row with tab()

[](#filling-a-table-row-with-tab)

```
$pointer = new ExcelPointer();
$pointer->down(3); // Move to row 4
for ($i = 0; $i < 10; $i++) {
	$cell = $pointer->tab();
	// $sheet->setCellValue($cell, "Row 4, Col $i");
}
```

### Using tab() with PHPSpreadsheet

[](#using-tab-with-phpspreadsheet)

```
$pointer = new ExcelPointer();
foreach (["Name", "Email", "Phone"] as $value) {
	$cell = $pointer->tab();
	$sheet->setCellValue($cell, $value);
}
$pointer->enter(); // Move to next row, first column
foreach (["Alice", "alice@example.com", "555-1234"] as $value) {
	$cell = $pointer->tab();
	$sheet->setCellValue($cell, $value);
}
```

### Resetting to first column of next row

[](#resetting-to-first-column-of-next-row)

```
$pointer->enter(); // Moves to first column of next row
```

### Checking boundaries before moving

[](#checking-boundaries-before-moving)

```
try {
	$pointer->right(20000); // Throws if out of bounds
} catch (OutOfBoundsException $e) {
	echo $e->getMessage();
}
```

XLS vs XLSX Boundaries
----------------------

[](#xls-vs-xlsx-boundaries)

By default, ExcelPointer uses XLSX boundaries (16384 columns, 1048576 rows). To use legacy XLS limits (256 columns, 65536 rows):

```
$pointer = new ExcelPointer('xls');
```

Movement Methods
----------------

[](#movement-methods)

- `right($n = 1)`: Move right by $n columns
- `left($n = 1)`: Move left by $n columns
- `down($n = 1)`: Move down by $n rows
- `up($n = 1)`: Move up by $n rows
- `enter()`: Move to the first column of the next row
- All movement methods check bounds and throw exceptions if the move is invalid.

Error Handling
--------------

[](#error-handling)

If you attempt to move out of bounds, an `OutOfBoundsException` is thrown:

```
try {
	$pointer->right(20000); // Too far for XLSX
} catch (OutOfBoundsException $e) {
	echo $e->getMessage();
}
```

If you pass an invalid parameter (e.g., negative or zero), an `InvalidArgumentException` is thrown.

Testing
-------

[](#testing)

Basic tests are provided in `tests/ExcelPointerTest.php`. Run them with:

```
php tests/ExcelPointerTest.php
```

Integration with PHPSpreadsheet
-------------------------------

[](#integration-with-phpspreadsheet)

ExcelPointer is designed to help you navigate cell coordinates and boundaries. You can use its output to set or get values in PHPSpreadsheet:

```
$sheet->setCellValue($pointer->coord(), 'Value');
$pointer->right();
$sheet->setCellValue($pointer->coord(), 'Next Value');
```

License
-------

[](#license)

MIT

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance46

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ea2fb0f1b3462fcaece723545d440d80b111725da2c9b3feb2987f5958f4a31?d=identicon)[JacketOfSeville](/maintainers/JacketOfSeville)

---

Top Contributors

[![JacketOfSeville](https://avatars.githubusercontent.com/u/40246717?v=4)](https://github.com/JacketOfSeville "JacketOfSeville (2 commits)")

### Embed Badge

![Health badge](/badges/jacketofseville-excel-pointer/health.svg)

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

###  Alternatives

[wordpress/phpdoc-parser

Static code parser for WordPress source.

24220.0k](/packages/wordpress-phpdoc-parser)[nickford/acf-swatch

This is a simple ACF Add-on field allowing the creation of color swatches that behave as radio buttons.

7610.2k1](/packages/nickford-acf-swatch)

PHPackages © 2026

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