PHPackages                             koenvanmeijeren/spreadsheet-reader - 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. koenvanmeijeren/spreadsheet-reader

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

koenvanmeijeren/spreadsheet-reader
==================================

Spreadsheet reader library for Excel, OpenOffice and structured text files

1.1(2y ago)02MITPHPPHP &gt;=8.3

Since Jan 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/KoenvanMeijeren/Spreadsheet-Reader)[ Packagist](https://packagist.org/packages/koenvanmeijeren/spreadsheet-reader)[ Docs](https://github.com/KoenvanMeijeren/Spreadsheet-Reader)[ RSS](/packages/koenvanmeijeren-spreadsheet-reader/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (19)Versions (3)Used By (0)

Spreadsheet reader
==================

[](#spreadsheet-reader)

This package provides a PHP spreadsheet reader that differs from others in that the main goal for it was efficient data extraction that could handle large (as in really large) files. So far it may not definitely be CPU, time or I/O-efficient, but at least it won't run out of memory (except maybe for XLS files).

So far, XLSX, ODS and text/CSV file parsing should be memory-efficient. XLS file parsing is done with php-excel-reader from  which, sadly, has memory issues with bigger spreadsheets, as it reads the data all at once and keeps it all in memory.

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

[](#installation)

```
composer require koenvanmeijeren/spreadsheet-reader
```

Requirements:
-------------

[](#requirements)

- PHP 8.0 or newer
- PHP must have Zip file support (see )

For XLSX-file reading

- PHP must have Simple XML &amp; XML read support

Usage:
------

[](#usage)

All data is read from the file sequentially, with each row being returned as a numeric array. This is about the easiest way to read a file:

```
$reader = new KoenVanMeijeren\SpreadsheetReader\SpreadsheetReader('example.xlsx');
foreach ($reader as $row)
{
	print_r($row);
}
```

However, now also multiple sheet reading is supported for file formats where it is possible. (In case of CSV, it is handled as if it only has one sheet.)

You can retrieve information about sheets contained in the file by calling the `sheets()` method which returns an array with sheet indexes as keys and sheet names as values. Then you can change the sheet that's currently being read by passing that index to the `changeSheet($Index)` method.

Example:

```
$reader = new KoenVanMeijeren\SpreadsheetReader\SpreadsheetReader('example.xlsx');
$sheets = $reader->sheets();
foreach ($sheets as $index => $name) {
	echo 'Sheet #'.$index.': '.$name;

	$reader->changeSheet($index);
	foreach ($reader as $row)
	{
		print_r($row);
	}
}
```

If a sheet is changed to the same that is currently open, the position in the file still reverts to the beginning, so as to conform to the same behavior as when changed to a different sheet.

Testing
-------

[](#testing)

From the command line:

```
composer run test
```

### Test coverage

[](#test-coverage)

Start the docker contains and enter the container:

```
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d
docker-compose -f docker-compose.yml -f docker-compose.dev.yml exec php /bin/bash
```

Run the tests with coverage generation:

```
composer run pest:coverage
```

### Running Benchmarks

[](#running-benchmarks)

#### Run Benchmark Tests

[](#run-benchmark-tests)

To execute the benchmark tests, use the following command:

```
composer run benchmark
```

This command runs the benchmarks with the default configuration and generates a default report.

#### Run Benchmark Baseline

[](#run-benchmark-baseline)

To establish a baseline for comparison, run the following command:

```
composer run benchmark:baseline
```

This command runs the benchmarks and tags the results as the baseline for future comparisons.

#### Run Benchmark Test Report

[](#run-benchmark-test-report)

To generate an aggregate report comparing the current benchmarks with the baseline, run:

```
composer run benchmark:test
```

This command provides insights into the performance changes between the baseline and the current state.

### Notes about library performance

[](#notes-about-library-performance)

- CSV and text files are read strictly sequentially so performance should be O(n);
- When, parsing XLS files, all the file content is read into memory so large XLS files can lead to "out of memory" errors;
- XLSX files use so-called "shared strings" internally to optimize for cases where the same string is repeated multiple times. Internally XLSX is an XML text that is parsed sequentially to extract data from it, however, in some cases these shared strings are a problem - sometimes Excel may put all, or nearly all the strings from the spreadsheet in the shared string file (which is a separate XML text), and not necessarily in the same order. The Worst case scenario is when it is in reverse order — for each string we need to parse the shared string XML from the beginning if we want to avoid keeping the data in memory. To that end, the XLSX parser has a cache for shared strings that is used if the total shared string count is not too high. In case you get out of memory errors, you can try adjusting the *SHARED\_STRING\_CACHE\_LIMIT* constant in KoenVanMeijeren\\SpreadsheetReader\\SpreadsheetReader\_XLSX to a lower one.

### TODOs:

[](#todos)

- ODS date formats;

### Licensing

[](#licensing)

All the code in this library is licensed under the MIT license as included in the LICENSE file, however, for now the library relies on php-excel-reader library for XLS file parsing, which is licensed under the PHP license.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 74.6% 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 ~1 days

Total

2

Last Release

856d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/aa80323c8cee8d1f22a2ed49ff9cd83d9158f630fd8b4f43d6c067bbbf0b15d1?d=identicon)[KoenvanMeijeren](/maintainers/KoenvanMeijeren)

---

Top Contributors

[![koenvanmeijeren-develto](https://avatars.githubusercontent.com/u/214485813?v=4)](https://github.com/koenvanmeijeren-develto "koenvanmeijeren-develto (88 commits)")[![KoenvanMeijeren](https://avatars.githubusercontent.com/u/52493874?v=4)](https://github.com/KoenvanMeijeren "KoenvanMeijeren (30 commits)")

---

Tags

excelxlsxlsxcsvspreadsheetodsOpenOffice

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/koenvanmeijeren-spreadsheet-reader/health.svg)

```
[![Health](https://phpackages.com/badges/koenvanmeijeren-spreadsheet-reader/health.svg)](https://phpackages.com/packages/koenvanmeijeren-spreadsheet-reader)
```

###  Alternatives

[phpoffice/phpspreadsheet

PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine

13.9k293.5M1.2k](/packages/phpoffice-phpspreadsheet)[nuovo/spreadsheet-reader

Spreadsheet reader library for Excel, OpenOffice and structured text files

669863.2k8](/packages/nuovo-spreadsheet-reader)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.1k57.6M128](/packages/openspout-openspout)[dcat/easy-excel

使用简单实用的语义化接口快速读写Excel文件

155373.4k23](/packages/dcat-easy-excel)[jgrygierek/batch-entity-import-bundle

Importing entities with preview and edit features for Symfony.

101.1M1](/packages/jgrygierek-batch-entity-import-bundle)[jgrygierek/sonata-batch-entity-import-bundle

Importing entities with preview and edit features for Sonata Admin.

10951.2k](/packages/jgrygierek-sonata-batch-entity-import-bundle)

PHPackages © 2026

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