jacketofseville/excel-pointer
Composer 安装命令:
composer require jacketofseville/excel-pointer
包简介
Excel pointer utility for XLS/XLSX navigation with PHP Spreadsheet packages.
README 文档
README
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
Install via Composer:
composer require jacketofseville/excel-pointer
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
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()
$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
$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
$pointer->enter(); // Moves to first column of next row
Checking boundaries before moving
try { $pointer->right(20000); // Throws if out of bounds } catch (OutOfBoundsException $e) { echo $e->getMessage(); }
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
right($n = 1): Move right by $n columnsleft($n = 1): Move left by $n columnsdown($n = 1): Move down by $n rowsup($n = 1): Move up by $n rowsenter(): Move to the first column of the next row- All movement methods check bounds and throw exceptions if the move is invalid.
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
Basic tests are provided in tests/ExcelPointerTest.php. Run them with:
php tests/ExcelPointerTest.php
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
MIT
jacketofseville/excel-pointer 适用场景与选型建议
jacketofseville/excel-pointer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 10 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「excel」 「spreadsheet」 「navigation」 「pointer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jacketofseville/excel-pointer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jacketofseville/excel-pointer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jacketofseville/excel-pointer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine
PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine
Yii2 export extension
PHP Excel Library
PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-23