PHPackages                             yzh52521/easy-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. yzh52521/easy-excel

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

yzh52521/easy-excel
===================

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

v1.0.1(3y ago)45.5k↓25%2MITPHPPHP ^7.2|^8.0

Since Jan 12Pushed 3y agoCompare

[ Source](https://github.com/yzh52521/easy-excel)[ Packagist](https://packagist.org/packages/yzh52521/easy-excel)[ Docs](https://github.com/yzh52521/easy-excel)[ RSS](/packages/yzh52521-easy-excel/feed)WikiDiscussions master Synced 1mo ago

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

EASY EXCEL
==========

[](#easy-excel)

 [![](https://camo.githubusercontent.com/ffe7adf17b1d38c79e0e81f80884e0e21f43129b2b96c7a123ea3bd032f09cb2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d3733383944382e7376673f7374796c653d666c6174)](https://github.com/yzh52521/easy-excel/blob/master/LICENSE) [ ![StyleCI](https://camo.githubusercontent.com/a0f468291b1a8883f44d51930cc9ef455d37fd0fcbebb8e65acf3e36277ba9db/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3231353733383739372f736869656c64) ](https://styleci.io/repos/215738797) [![](https://camo.githubusercontent.com/8d5826d9dcb79decde4ade2da711d8287b45fe1d1ed872a7e27f690440812df4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f797a6835323532312f656173792d657863656c2e7376673f636f6c6f723d343039394445)](https://github.com/yzh52521/easy-excel/releases) [![](https://camo.githubusercontent.com/f5e150901cac2676c5b43035bbe779dd84188442d1e574af38055b96939b8111/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f797a6835323532312f656173792d657863656c2e7376673f636f6c6f723d)](https://packagist.org/packages/yzh52521/easy-excel) [![](https://camo.githubusercontent.com/1cd5dc8e3ee87cf05051a5859df96b13c0a01ebfc3fc0411353cbb10a937cfa7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e322b2d3539613966382e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/1cd5dc8e3ee87cf05051a5859df96b13c0a01ebfc3fc0411353cbb10a937cfa7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e322b2d3539613966382e7376673f7374796c653d666c6174)

`Easy Excel`是一个基于 [openspout/openspout](https://github.com/openspout/openspout) 封装的Excel读写工具，可以帮助开发者更快速更轻松地读写Excel文件， 并且无论读取多大的文件只需占用极少的内存。

> 由于`openspout/openspout`只支持读写`xlsx`、`csv`、`ods`等类型文件，所以本项目目前也仅支持读写这三种类型的文件。

文档
--

[](#文档)

[文档](https://jqhph.github.io/easy-excel/)

环境
--

[](#环境)

- PHP &gt;= 7.2
- PHP extension php\_zip
- PHP extension php\_xmlreader
- openspout/openspout &gt;= 3.0
- league/flysystem &gt;= 1.0

安装
--

[](#安装)

```
composer require yzh52521/easy-excel
```

### 快速开始

[](#快速开始)

#### 导出

[](#导出)

下载

```
use Dcat\EasyExcel\Excel;

$array = [
    ['id' => 1, 'name' => 'Brakus', 'email' => 'treutel@eg.com', 'created_at' => '...'],
    ...
];

$headings = ['id' => 'ID', 'name' => '名称', 'email' => '邮箱'];

// xlsx
Excel::export($array)->headings($headings)->download('users.xlsx');

// csv
Excel::export($array)->headings($headings)->download('users.csv');

// ods
Excel::export($array)->headings($headings)->download('users.ods');
```

保存

```
use Dcat\EasyExcel\Excel;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;

$array = [...];

// 保存到当前服务器
Excel::export($array)->store('/tmp/users.xlsx');

// 使用 filesystem
$adapter = new Local(__DIR__);

$filesystem = new Filesystem($adapter);

Excel::export($array)->disk($filesystem)->store('users.xlsx');

// 使用yzh52521/think-filesystem

Excel::export($array)->disk('local')->store('users.xlsx');
// 也可以
$filesystem = \yzh52521\filesystem\facade\Filesystem::disk('local')->getDriver();
Excel::export('users.xlsx')->disk($filesystem)->store('users.xlsx');
```

获取文件内容

```
use Dcat\EasyExcel\Excel;

$array = [...];

$xlsxContents = Excel::xlsx($array)->raw();

$csvContents = Excel::csv($array)->raw();

$odsContents = Excel::ods($array)->raw();
```

更多导出功能请参考[文档](https://jqhph.github.io/easy-excel/docs/master/export.html)。

#### 导入

[](#导入)

读取所有表格数据

```
use Dcat\EasyExcel\Excel;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;

$headings = ['id', 'name', 'email'];

// 导入xlsx
$allSheets = Excel::import('/tmp/users.xlsx')->headings($headings)->toArray();

// 使用filesystem
$adapter = new Local(__DIR__);

$filesystem = new Filesystem($adapter);

$allSheets = Excel::import('users.xlsx')->disk($filesystem)->headings($headings)->toArray();

print_r($allSheets); // ['Sheet1' => [['id' => 1, 'name' => 'Brakus', 'email' => 'treutel@eg.com', 'created_at' => '...']]]
```

遍历表格

```
use Dcat\EasyExcel\Excel;
use Dcat\EasyExcel\Contracts\Sheet as SheetInterface;
use Dcat\EasyExcel\Support\SheetCollection;

// 导入xlsx
Excel::import('/tmp/users.xlsx')->each(function (SheetInterface $sheet) {
    // 获取表格名称，如果是csv文件，则此方法返回空字符串
    $sheetName = $sheet->getName();

    // 表格序号，从 0 开始
    $sheetIndex = $sheet->getIndex();

    // 是否是最后一次保存前打开的表格
    $isActive = $sheet->isActive();

    // 分块处理表格数据
    $sheet->chunk(100, function (SheetCollection $collection) {
        $chunkArray = $collection->toArray();

        print_r($chunkArray); // [['id' => 1, 'name' => 'Brakus', 'email' => 'treutel@eg.com', 'created_at' => '...']]
    });

});
```

获取指定表格内容

```
use Dcat\EasyExcel\Excel;
use Dcat\EasyExcel\Support\SheetCollection;

// 获取第一个表格内容
$firstSheet = Excel::import('/tmp/users.xlsx')->first()->toArray();

// 获取最后一次保存前打开的表格内容
$activeSheet = Excel::import('/tmp/users.xlsx')->active()->toArray();

// 获取指定名称或序号的表格内容
$sheet = Excel::import('/tmp/users.xlsx')->sheet('Sheet1')->toArray();
$sheet = Excel::import('/tmp/users.xlsx')->sheet(0)->toArray();

// 分块处理表格内容
Excel::import('/tmp/users.xlsx')
    ->first()
    ->chunk(1000, function (SheetCollection $collection) {
        $collection = $collection->keyBy('id');
    });
```

更多导入功能请参考[文档](https://jqhph.github.io/easy-excel/docs/master/import.html)。

License
-------

[](#license)

[The MIT License (MIT)](LICENSE).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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 ~113 days

Total

2

Last Release

1106d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15060466?v=4)[听风吹雨](/maintainers/yuanzhihai)[@yuanzhihai](https://github.com/yuanzhihai)

---

Top Contributors

[![jqhph](https://avatars.githubusercontent.com/u/20312339?v=4)](https://github.com/jqhph "jqhph (76 commits)")[![yuanzhihai](https://avatars.githubusercontent.com/u/15060466?v=4)](https://github.com/yuanzhihai "yuanzhihai (14 commits)")[![ljyljy0211](https://avatars.githubusercontent.com/u/1272007?v=4)](https://github.com/ljyljy0211 "ljyljy0211 (2 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (2 commits)")[![ihipop](https://avatars.githubusercontent.com/u/423077?v=4)](https://github.com/ihipop "ihipop (1 commits)")

---

Tags

streamexcelxlsxcsvofficespreadsheetodsreadbox spouteasy excelopenspout

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/yzh52521-easy-excel/health.svg)

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

###  Alternatives

[dcat/easy-excel

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

155373.4k24](/packages/dcat-easy-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)

PHPackages © 2026

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