PHPackages                             sunmoon/yii2-phpspreadsheet - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. sunmoon/yii2-phpspreadsheet

ActiveLibrary[File &amp; Storage](/categories/file-storage)

sunmoon/yii2-phpspreadsheet
===========================

Yii2处理Excel文件， 修改自moonlandsoft/yii2-phpexcel。

1.2.0(7y ago)42.4k[2 issues](https://github.com/arieslee/yii2-phpspreadsheet/issues)MITPHP

Since Apr 27Pushed 7y agoCompare

[ Source](https://github.com/arieslee/yii2-phpspreadsheet)[ Packagist](https://packagist.org/packages/sunmoon/yii2-phpspreadsheet)[ Docs](https://github.com/arieslee/yii2-phpspreadsheet)[ RSS](/packages/sunmoon-yii2-phpspreadsheet/feed)WikiDiscussions master Synced 1mo ago

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

说明
==

[](#说明)

Yii2 处理 Excel 文件， 修改自[moonlandsoft/yii2-phpexcel](https://github.com/moonlandsoft/yii2-phpexcel)。

修改项:

```
1. 由于phpoffice/phpexcel已经弃用，更新为phpoffice/phpspreadsheet
2. 导出文件后退出脚本导致程序后续代码无法执行的问题
3. 增加按行读取excel的功能 1.0.8
4. 提供获取文件总行的的功能 1.0.8
5. 修复 BUG : 分页导入数据时，读取第二页时，无法获取第一行的数据作为数组的键值
6. 增加配置项 storeFile ,作为临时储存第一行的数据作为键值，默认为null
7. 增加配置项 dropKeysRow true/false，读取第一页的数据时，是否作为数组键值的行从数组中丢弃，默认为false
8. 增加验证功能，readEndRow不能小于readStartRow

```

安装
--

[](#安装)

1. 安装包文件

    ```
    $ composer require sunmoon/yii2-phpspreadsheet '*'
    ```

使用
--

[](#使用)

1. 代码中使用参见 [moonlandsoft/yii2-phpexcel](https://github.com/moonlandsoft/yii2-phpexcel)
2. 如何按行读取excel

```
use sunmoon\phpspreadsheet\Excel as ExcelHelper;
public function actionReadExcel(){
    $fileName = 'demo.xlsx';
    //从第1行读取到第7行
    $data = ExcelHelper::import($fileName, ['readStartRow'=>1, 'readEndRow'=>7, ]);
    return $data;
}

```

3. 如何按行读取excel的总行数

```
use sunmoon\phpspreadsheet\Excel as ExcelHelper;
public function actionReadExcelRows(){
    $fileName = 'demo.xlsx';
    $data = ExcelHelper::getHighestRows($fileName);
    return $data;
}

```

其他
--

[](#其他)

1. 从phpexcel迁移到phpspreadsheet的注意事项，[migration-from-PHPExcel](https://phpspreadsheet.readthedocs.io/en/develop/topics/migration-from-PHPExcel/)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity71

Established project with proven stability

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

Recently: every ~41 days

Total

14

Last Release

2638d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/756eb263863387688e6d5bcdf34bb00d68c0269602e66a17e676f437433529ea?d=identicon)[sunmoon](/maintainers/sunmoon)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/sunmoon-yii2-phpspreadsheet/health.svg)

```
[![Health](https://phpackages.com/badges/sunmoon-yii2-phpspreadsheet/health.svg)](https://phpackages.com/packages/sunmoon-yii2-phpspreadsheet)
```

###  Alternatives

[mihaildev/yii2-elfinder

Yii2 ElFinder

169658.8k52](/packages/mihaildev-yii2-elfinder)[liyunfang/yii2-upload-behavior

Upload behavior for Yii 2

161.7k](/packages/liyunfang-yii2-upload-behavior)

PHPackages © 2026

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