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

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

nealyip/spreadsheet
===================

Spreadsheet read writer abstraction for box/spout and phpexcel

v1.1.2(7y ago)0182MITPHPPHP &gt;=7

Since Jul 26Pushed 7y ago1 watchersCompare

[ Source](https://github.com/nealyip/spreadsheet)[ Packagist](https://packagist.org/packages/nealyip/spreadsheet)[ RSS](/packages/nealyip-spreadsheet/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (6)Versions (19)Used By (0)

Description
-----------

[](#description)

Spreadsheet read writer abstraction for box/spout and phpexcel, support Laravel

Updates
-------

[](#updates)

v1.1.2 Fix header for downloading xlsx, throw generic exception on boxspout write function
v1.1.0 Add PHPSpreadsheet. PHPExcel was deprecated. Allow use of class with namespace for SPREADSHEET\_WRITER and SPREADSHEET\_READER from .env

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

[](#installation)

```
composer require nealyip/spreadsheet

```

Add this provider to config/app.php

```
\Nealyip\Spreadsheet\SpreadsheetServiceProvider::class,
```

### Configuration

[](#configuration)

Publish config

```
php artisan vendor:publish --provider="Nealyip\Spreadsheet\SpreadsheetServiceProvider"

```

Simply change config/spreadsheet.php to select one spreadsheet data provider
PHPSpreadsheet is used by default

or configure on the .env file

```
SPREADSHEET_WRITER=PHPSpreadsheet
SPREADSHEET_READER=BoxSpout
```

Or if you implement your own Writer or Reader, you may use full class name here.

```
SPREADSHEET_WRITER=App\Spreadsheet\CustomerWriter
```

be remember to implement

```
Nealyip\Spreadsheet\Writer

```

How to use
----------

[](#how-to-use)

Dependency Injection

### Reader

[](#reader)

```
use Nealyip\Spreadsheet\Reader;
class Sth{
    protected $_reader;

    public function __construct(Reader $reader) {
        $this->_reader = $reader;
    }

    public function readFile($filename){
        $data = $this->_reader->toKeyValueArray($filename);

    }
```

### Reader using generator

[](#reader-using-generator)

```
use Nealyip\Spreadsheet\Reader;
class Sth{
    protected $_reader;

    public function __construct(Reader $reader) {
        $this->_reader = $reader;
    }

    public function readFile($filename){
        $data = $this->_reader->toKeyValueArray($filename);
        foreach ($this->_reader->read($filename) as $item){
            // $item is a row in array form
        }
    }
```

### Writer

[](#writer)

```
use Nealyip\Spreadsheet\Writer;
class Sth{
    protected $_writer;

    public function __construct(Writer $writer) {
        $this->_writer = $writer;
    }

    public function writeFile($filename){

        $headers = ['Name', 'Gender', 'Age'];

        $this->_writer
            ->setup("report.xlsx")
            ->useSheet('Report')
            ->writeArray([['Tom','M','20'], ['Ann','F','24']], $headers)
            ->save();

    }
```

### Writer using generator

[](#writer-using-generator)

```
use Nealyip\Spreadsheet\Writer;
class Sth{
    protected $_writer;

    public function __construct(Writer $writer) {
        $this->_writer = $writer;
    }

    /**
     * Data source from DB/API etc
     *
     * @return \Generator
     */
    protected function _data(){
        $data = [['Tom','M','20'], ['Ann','F','24']];
        foreach ($data as $d) {
            yield $d;
        }
    }

    public function writeFile($filename){

        $headers = ['Name', 'Gender', 'Age'];

        $this->_writer
            ->setup("report.xlsx")
            ->useSheet('Report')
            ->write($this->_data(), $headers)
            ->save();
    }
```

### Write to local file

[](#write-to-local-file)

```
use Nealyip\Spreadsheet\Writer;
class Sth{
    protected $_writer;

    public function __construct(Writer $writer) {
        $this->_writer = $writer;
    }

    /**
     * Data source from DB/API etc
     *
     * @return \Generator
     */
    protected function _data(){
        $data = [['Tom','M','20'], ['Ann','F','24']];
        foreach ($data as $d) {
            yield $d;
        }
    }

    public function writeFile($filename){

        $headers = ['Name', 'Gender', 'Age'];

        $this->_writer
            ->setup("report.xlsx", false)
            ->useSheet('Report')
            ->write($this->_data(), $headers)
            ->save();
    }
```

Memory limit and execution timeout
----------------------------------

[](#memory-limit-and-execution-timeout)

If you have encounter memory exhaust problem, you may tune the memory limit by

```
ini_set('memory_limit', '1000M');
```

or for execution timeout

```
ini_set('max_execution_time', 300);
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity72

Established project with proven stability

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 ~20 days

Recently: every ~1 days

Total

18

Last Release

2872d ago

PHP version history (2 changes)v1.0.1PHP &gt;=5.6

v1.0.10PHP &gt;=7

### Community

Maintainers

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

---

Tags

excellaravelphp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

7.3k87.6M278](/packages/barryvdh-laravel-dompdf)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[knackline/excel-to-x

Laravel Package that converts excel to JSON/collection

448.1k](/packages/knackline-excel-to-x)

PHPackages © 2026

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