PHPackages                             overlu/mini-excel - 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. overlu/mini-excel

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

overlu/mini-excel
=================

Excel import/export for Mini

v1.0.0(2y ago)0440MITPHPPHP ^8.1

Since May 16Pushed 2y ago1 watchersCompare

[ Source](https://github.com/overlu/mini-excel)[ Packagist](https://packagist.org/packages/overlu/mini-excel)[ RSS](/packages/overlu-mini-excel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

> 感谢 rap2hpoutre/fast-excel 提供了优秀扩展 具体使用说明请传送至

Quick start
-----------

[](#quick-start)

Install via composer:

```
composer require overlu/mini-excel

```

Export a Model to `.xlsx` file:

```
use MiniExcel\Excel;
use App\Models\User;

// Load users
$users = User::all();

// Export all users
(new Excel($users))->export('file.xlsx');
```

Export
------

[](#export)

Export a Model or a **Collection**:

```
$list = collect([
    [ 'id' => 1, 'name' => 'Jane' ],
    [ 'id' => 2, 'name' => 'John' ],
]);

(new Excel($list))->export('file.xlsx');
```

Export `xlsx`, `ods` and `csv`:

```
$invoices = App\Invoice::orderBy('created_at', 'DESC')->get();
(new Excel($invoices))->export('invoices.csv');
```

Export only some attributes specifying columns names:

```
(new Excel(User::all()))->export('users.csv', function ($user) {
    return [
        'Email' => $user->email,
        'First Name' => $user->firstname,
        'Last Name' => strtoupper($user->lastname),
    ];
});
```

Download (from a controller method):

```
return (new Excel(User::all()))->download('file.xlsx');
```

Import
------

[](#import)

`import` returns a Collection:

```
$collection = (new Excel)->import('file.xlsx');
```

Import a `csv` with specific delimiter, enclosure characters and "gbk" encoding:

```
$collection = (new Excel)->configureCsv(';', '#', 'gbk')->import('file.csv');
```

Import and insert to database:

```
$users = (new Excel)->import('file.xlsx', function ($line) {
    return User::create([
        'name' => $line['Name'],
        'email' => $line['Email']
    ]);
});
```

Facades
-------

[](#facades)

Using the Facade, you will not have access to the constructor. You may set your export data using the `data` method.

```
$list = collect([
    [ 'id' => 1, 'name' => 'Jane' ],
    [ 'id' => 2, 'name' => 'John' ],
]);

Excel::data($list)->export('file.xlsx');
```

Global helper
-------------

[](#global-helper)

Excel provides a convenient global helper to quickly instantiate the Excel class anywhere in a Laravel application.

```
$collection = Excel()->import('file.xlsx');
Excel($collection)->export('file.xlsx');
```

Advanced usage
--------------

[](#advanced-usage)

### Export multiple sheets

[](#export-multiple-sheets)

Export multiple sheets by creating a `SheetCollection`:

```
$sheets = new SheetCollection([
    User::all(),
    Project::all()
]);
(new Excel($sheets))->export('file.xlsx');
```

Use index to specify sheet name:

```
$sheets = new SheetCollection([
    'Users' => User::all(),
    'Second sheet' => Project::all()
]);
```

### Import multiple sheets

[](#import-multiple-sheets)

Import multiple sheets by using `importSheets`:

```
$sheets = (new Excel)->importSheets('file.xlsx');
```

You can also import a specific sheet by its number:

```
$users = (new Excel)->sheet(3)->import('file.xlsx');
```

Import multiple sheets with sheets names:

```
$sheets = (new Excel)->withSheetsNames()->importSheets('file.xlsx');
```

### Export large collections with chunk

[](#export-large-collections-with-chunk)

Export rows one by one to avoid `memory_limit` issues [using `yield`](https://www.php.net/manual/en/language.generators.syntax.php):

```
function usersGenerator() {
    foreach (User::cursor() as $user) {
        yield $user;
    }
}

// Export consumes only a few MB, even with 10M+ rows.
(new Excel(usersGenerator()))->export('test.xlsx');
```

### Add header and rows style

[](#add-header-and-rows-style)

Add header and rows style with `headerStyle` and `rowsStyle` methods.

```
use OpenSpout\Common\Entity\Style\Style;

$header_style = (new Style())->setFontBold();

$rows_style = (new Style())
    ->setFontSize(15)
    ->setShouldWrapText()
    ->setBackgroundColor("EDEDED");

return (new Excel($list))
    ->headerStyle($header_style)
    ->rowsStyle($rows_style)
    ->download('file.xlsx');
```

Why?
----

[](#why)

Excel is intended at being Laravel-flavoured [Spout](https://github.com/box/spout): a simple, but elegant wrapper around [Spout](https://github.com/box/spout) with the goal of simplifying **imports and exports**. It could be considered as a faster (and memory friendly) alternative to [Laravel Excel](https://laravel-excel.com/), with less features. Use it only for simple tasks.

Benchmarks
----------

[](#benchmarks)

> Tested on a MacBook Pro 2015 2,7 GHz Intel Core i5 16 Go 1867 MHz DDR3. Testing a XLSX export for 10000 lines, 20 columns with random data, 10 iterations, 2018-04-05. **Don't trust benchmarks.**

Average memory peak usageExecution timeLaravel Excel123.56 M11.56 sExcel2.09 M2.76 sStill, remember that [Laravel Excel](https://laravel-excel.com/) **has many more features.**

###  Health Score

24

↓

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Unknown

Total

1

Last Release

731d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8fb4bb996611914fba924d0b7c1ddc93eadc34bbd0eb119422dc067f619e5e5c?d=identicon)[overlu](/maintainers/overlu)

---

Top Contributors

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

---

Tags

excelswoolemini

### Embed Badge

![Health badge](/badges/overlu-mini-excel/health.svg)

```
[![Health](https://phpackages.com/badges/overlu-mini-excel/health.svg)](https://phpackages.com/packages/overlu-mini-excel)
```

###  Alternatives

[rap2hpoutre/fast-excel

Fast Excel import/export for Laravel

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

Symfony Bundle to read or write Excel file (including pdf, xlsx, odt), using phpoffice/phpspreadsheet library (replacement of phpoffice/phpexcel, abandonned)

15332.0k](/packages/onurb-excel-bundle)

PHPackages © 2026

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