PHPackages                             xjimmy906/spout - 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. xjimmy906/spout

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

xjimmy906/spout
===============

基于box/spout的一个快速读写excel文件(csx,xlsx and ods)的php库(详细文档:https://opensource.box.com/spout/)

1.0.1(5y ago)113MITPHPPHP &gt;=7.1CI failing

Since Jan 20Pushed 5y ago1 watchersCompare

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

READMEChangelogDependencies (4)Versions (4)Used By (0)

### Writer

[](#writer)

基于[box/spout ](https://opensource.box.com/spout/) 的一个快速读写excel文件(csx,xlsx and ods)的php库

```
use xjimmy906\Writer;
use Box\Spout\Common\Type;
$writer = new Writer([
    'fileName'=>'/Users/xujw/Downloads/test.xlsx',
    'type'=>Type::XLSX,
    'download'=>false,//true下载
]);
//设置head头，第二个参数可设置样式
$writer->setHeader(['姓名',"性别"]);
//添加一行数据，第二个参数可设置样式，第三个参数可配置一个回调函数
$writer->addRow(['jack','man']);
//添加多行数据，第二个参数可设置样式，第三个参数可配置一个回调函数
$writer->addRows([['lilei','man'],['hanmeimei','woman']]);
//使用第三参数回调处理数据
$writer->addRows([['lilei','man'],['hanmeimei','woman']],null,function($data,$w){
    foreach($data as &$val){
        if($val[1] === "man"){
            $val[1] = "男";
        }elseif([$val[1] === 'woman']){
            $val[1] = "女";
        }
    }
    unset($val);
    return $data;
});
//释放资源
$writer->finish();
```

### Reader

[](#reader)

```
use xjimmy906\Reader;
use Box\Spout\Common\Type;
$reader = new Reader([
    'fileName'=>'/Users/xujw/Downloads/test.xlsx',
]);
//设置读取的sheet
$reader->setReaderSheet(0);
//读取当前sheet中的数据总条数
$reader->count();
//迭代器读取每一行数据
foreach($reader->rowIterator() as $row){
    //box/spout 3.0.0+ 版本以上返回Row对象，而不是包含行值的数组(3.0.0版本以前返回的为数组)

    $rowAsArray = $row->toArray();  //转化为数组,兼容2.0写法
    // OR
    $cellsArray = $row->getCells(); //这可以用来访问单元格的详细信息
}
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Total

2

Last Release

1936d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/695bb01ea3c3caf51df773713e791bcad2fb56af8d94f12f82ddb21ab197247a?d=identicon)[xjw1990](/maintainers/xjw1990)

---

Top Contributors

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

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/xjimmy906-spout/health.svg)

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

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M124](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

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