PHPackages                             mahmud/sheet - 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. mahmud/sheet

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

mahmud/sheet
============

Excel and CSV file reader

1.1.0(6y ago)301341[1 issues](https://github.com/mahmudkuet11/sheet/issues)MITPHPPHP ^7.1.3CI failing

Since Dec 6Pushed 6y ago2 watchersCompare

[ Source](https://github.com/mahmudkuet11/sheet)[ Packagist](https://packagist.org/packages/mahmud/sheet)[ RSS](/packages/mahmud-sheet/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (8)Dependencies (3)Versions (10)Used By (0)

[![Build Status](https://camo.githubusercontent.com/36ac87db6d34fa27b93c4cd70f43b1b9681141885367d61172685f545081501a/68747470733a2f2f7472617669732d63692e6f72672f6d61686d75646b75657431312f73686565742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mahmudkuet11/sheet)[![Latest Stable Version](https://camo.githubusercontent.com/43fa45abe4fb4d0fdc7cb77701a6a891ec3fd15fc2c7447d54cf5be239a8e002/68747470733a2f2f706f7365722e707567782e6f72672f6d61686d75642f73686565742f762f737461626c65)](https://packagist.org/packages/mahmud/sheet)[![License](https://camo.githubusercontent.com/4db424d6fddb9e2904814e328073fa638b6b7ddb9255cc232186484f629e8dad/68747470733a2f2f706f7365722e707567782e6f72672f6d61686d75642f73686565742f6c6963656e7365)](https://packagist.org/packages/mahmud/sheet)[![composer.lock](https://camo.githubusercontent.com/19fa47875d60adf3ac477f2f79de4884df91c42b29a50f265152bf09993e7e0a/68747470733a2f2f706f7365722e707567782e6f72672f6d61686d75642f73686565742f636f6d706f7365726c6f636b)](https://packagist.org/packages/mahmud/sheet)

A clean and beautiful API to read Excel/CSV sheet. This is a wrapper around [box/spout](https://github.com/box/spout) package.

Installation
============

[](#installation)

```
composer require mahmud/sheet
```

Requirements
============

[](#requirements)

- php: ^7.1.3
- box/spout: ^3.0

Usage
=====

[](#usage)

Simple Example
--------------

[](#simple-example)

Let's assume we have a csv file like this.

IDNameAge1Mahmud272Mohor263Ayman1```
use Mahmud\Sheet\SheetReader;

SheetReader::makeFromCsv('/path-to-csv-file/example-file.csv')
            ->delimiter(",")                        // Optional: You can set delimiter for CSV file
            ->ignoreRow(0)                          // Optional: Skip the header row
            ->columns(['id', 'name', 'age'])        // Arbitary column name that will be mapped sequentially for each row
            ->onEachRow(function($row, $index){
                // This callback will be executed for each row
                var_dump($row);     // Current row in associative array
                var_dump($index);   // Current index of the row
            })->read();
```

Middleware
----------

[](#middleware)

You can modify data of each row with middleware. See the following example

```
use Mahmud\Sheet\SheetReader;

SheetReader::makeFromCsv('/path-to-csv-file/example-file.csv')
            ->delimiter(",")
            ->ignoreRow(0)
            ->columns(['id', 'name', 'age'])
            ->applyMiddleware(function($row, $index){
                $row['age'] = $row['age'] . " Years";

                return $row;
            })
            ->onEachRow(function($row, $index){
                var_dump($row);
            })->read();
```

Another example using class as middleware

```
class AgeMiddleware{
    public function handle($row, $index) {
        $row['age'] = $row['age'] . " Years";

        return $row;
    }
}

SheetReader::makeFromCsv('/path-to-csv-file/example-file.csv')
            ->delimiter(",")
            ->ignoreRow(0)
            ->columns(['id', 'name', 'age'])
            ->applyMiddleware(new AgeMiddleware)
            ->onEachRow(function($row, $index){
                var_dump($row);
            })->read();
```

Also you can pass array of middlewares

```
SheetReader::makeFromCsv('/path-to-csv-file/example-file.csv')
            ->delimiter(",")
            ->ignoreRow(0)
            ->columns(['id', 'name', 'age'])
            ->applyMiddleware([
                new AgeMiddleware,
                new AnotherMiddleware,
            ])
            ->onEachRow(function($row, $index){
                var_dump($row);
            })->read();
```

If you return `null` from middleware, That row will be skipped and won't pass to `onEachRow` handler.

```
SheetReader::makeFromCsv('/path-to-csv-file/example-file.csv')
            ->delimiter(",")
            ->ignoreRow(0)
            ->columns(['id', 'name', 'age'])
            ->applyMiddleware(function($row){
                if($row['id'] == 1){
                    return null;
                }

                return $row;
            })
            ->onEachRow(function($row, $index){
                var_dump($row);
            })->read();
```

Count total rows
----------------

[](#count-total-rows)

```
$total = SheetReader::makeFromCsv('/path-to-csv-file/example-file.csv')
                        ->totalRows();

var_dump($total);       // 4
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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

Every ~4 days

Total

8

Last Release

2325d ago

Major Versions

0.4.0 → V1.0.02020-01-03

### Community

Maintainers

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

---

Top Contributors

[![mahmudkuet11](https://avatars.githubusercontent.com/u/5725014?v=4)](https://github.com/mahmudkuet11 "mahmudkuet11 (3 commits)")

---

Tags

excelcsvsheet

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mahmud-sheet/health.svg)

```
[![Health](https://phpackages.com/badges/mahmud-sheet/health.svg)](https://phpackages.com/packages/mahmud-sheet)
```

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[rap2hpoutre/fast-excel

Fast Excel import/export for Laravel

2.3k24.9M47](/packages/rap2hpoutre-fast-excel)[openspout/openspout

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

1.1k57.6M131](/packages/openspout-openspout)[gotenberg/gotenberg-php

A PHP client for interacting with Gotenberg, a developer-friendly API for converting numerous document formats into PDF files, and more!

3685.2M19](/packages/gotenberg-gotenberg-php)[nuovo/spreadsheet-reader

Spreadsheet reader library for Excel, OpenOffice and structured text files

669863.2k8](/packages/nuovo-spreadsheet-reader)[dcat/easy-excel

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

155373.4k24](/packages/dcat-easy-excel)

PHPackages © 2026

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