the-pantry / lightweight-spreadsheet
A lightweight php library for reading spreadsheet files
Package info
github.com/The-Pantry-App/lightweight-spreadsheet
pkg:composer/the-pantry/lightweight-spreadsheet
v1.0.1
2026-07-19 12:32 UTC
Requires
- php: ^8.4
- ext-xmlreader: *
- ext-zip: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^13.2
- symfony/var-dumper: ^8.1
README
Lightweight Spreadsheet
A lightweight PHP library for reading spreadsheet files with a focus on low memory usage and simplicity.
Features
- XLSX Support: Read modern Excel files.
- Generator Based: Uses PHP Generators to iterate over sheets and rows, keeping memory usage low.
- Simple API: Easy to use interface for accessing data.
- PHP 8.4+ Ready: Built with the latest PHP features.
Requirements
- PHP: ^8.4
- Extensions:
ext-xmlreader,ext-zip
Installation
To install, use composer:
composer require the-pantry/lightweight-spreadsheet
Usage
Opening a Spreadsheet
use ThePantry\LightweightSpreadsheet\SpreadsheetReader; $spreadsheet = SpreadsheetReader::open('path/to/spreadsheet.xlsx');
Iterating through Sheets, Rows, and Cells
foreach ($spreadsheet->getSheets() as $sheet) { echo "Sheet: " . $sheet->name . PHP_EOL; foreach ($sheet->getRows() as $row) { foreach ($row->getCells() as $cell) { echo "Cell " . $cell->coordinate->toString() . ": " . $cell->value . PHP_EOL; } } }
Accessing a Specific Sheet or Row
$sheet = $spreadsheet->getSheetByName('Sheet1'); $row = $sheet?->getRow(1);
Accessing a Specific Cell
$sheet = $spreadsheet->getSheetByName('Sheet1'); $cell = $sheet?->getCell('A1'); echo "Cell " . $cell->coordinate->toString() . ": " . $cell->value . PHP_EOL;
Project Structure
src/: Library source code.Spreadsheet/: Core spreadsheet logic and formats.SpreadsheetReader.php: Main entry point.
tests/: Unit and integration tests.
Development Scripts
The following scripts are available via Composer:
- Run Tests:
composer run test - Static Analysis:
composer run analyse - Check Code Style:
composer run cs-check - Fix Code Style:
composer run cs-fix
License
The MIT License (MIT). Please see License File for more information.