PHPackages                             fan1992/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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. fan1992/phpspreadsheet

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

fan1992/phpspreadsheet
======================

phpspreadsheet

0.5.0(5y ago)110[1 issues](https://github.com/fan1992/phpspreadsheet/issues)[1 PRs](https://github.com/fan1992/phpspreadsheet/pulls)MITPHP

Since Jun 20Pushed 5y agoCompare

[ Source](https://github.com/fan1992/phpspreadsheet)[ Packagist](https://packagist.org/packages/fan1992/phpspreadsheet)[ RSS](/packages/fan1992-phpspreadsheet/feed)WikiDiscussions master Synced 3d ago

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

phpspreadshhet
==============

[](#phpspreadshhet)

phpspreadshhet 读取，导出

安装
==

[](#安装)

```
    composer require fan1992/phpspreadsheet

```

使用示例
====

[](#使用示例)

```
    use Fan1992\Phpspreadsheet\Excel;
    $excel = new Excel();

```

读取文档（默认只读取第一个sheet）
===================

[](#读取文档默认只读取第一个sheet)

```
    $data = $excel->read('./test.xlsx');
    print_r($data);

```

一次读取多个sheet
===========

[](#一次读取多个sheet)

```
    $excel->sheetNames = ['data_a'=>'表1','data_b'=>'表2','data_c'=>'Sheet3'];
    $data = $excel->read('./test.xlsx');
    print_r($data);

```

一次读取所有sheet
===========

[](#一次读取所有sheet)

```
    $excel = new Excel();
    $excel->autoReadAllSheets = true;
    $data = $excel->read('./test.xlsx');
    print_r($data);

```

导出
==

[](#导出)

```
    $header = ['提提1', 'title2', '标题3', '测试测试']; //表头，即第一行
    $data = [//具体数据，支持多维数组（合并单元格）
        ['12', ['阿斯顿发','asdf','2019-06-19'], '是的', '沙箱'],
        ['撒发顺丰的', ['1','23','撒旦法师'], '2019-06-19', 'asdasdfas']
    ];
    $width = [30,0,40,60]; //列宽度，为0或没有则自动适应
    $excel->export($data, $header,'test'.time(),null, 'mysheet', $width);

```

导出多个sheet
=========

[](#导出多个sheet)

```
    $excel1Data = [
        'data'      => [
            ['12', ['阿斯顿发', 'asdf', '2019-06-19'], '是的', '沙箱'],
            ['asd', ['阿斯顿发', '22', '2019-06-19'], '是', '沙asdf箱'],
        ],
        'header'    => ['header1', '标题2', '333', '超级长超级长超级长超级长超级长超级长超级长的标题'],
        'sheetName' => '1211sheet1',
        'width'     => [5, 0, 5]
    ];
    $excel2Data = [
        'data'      => [
            ['12', ['阿斯顿发', 'asdf', '2019-06-19'], '是的', '沙箱'],
            ['asd', ['阿斯顿发', '22', '2019-06-19'], '是', '沙asdf箱'],
        ],
        'header'    => ['header1', '标题2', '333', '超级长超222222级长超级长超级长超级长超级长超级长的标题'],
        'sheetName' => '',
        'width'     => []
    ];
    $excel3Data = [
        'data'      => [
            ['12', ['阿斯顿发', 'asdf', '2019-06-19'], '是的', '沙333箱'],
            ['asd', ['阿斯顿发', '22', '2019-06-19'], '是3333', '沙asdf箱'],
        ],
        'header'    => ['header1', '标题2', '333', '超级长超级长超3333级长超级长超级长超级长超级长的标题'],
        'sheetName' => '导出sheet3',
        'width'     => []
    ];
    $data       = [$excel1Data, $excel2Data, $excel3Data];
    $excel->mutiSheetExport($data, 'muti' . time(), Sheet::TYPE_XLSX);

```

其它
==

[](#其它)

```
    $readFirstLine = false;//是否读取首行
    $down = true; //是否直接下载，false则保存文件在服务器上

    支持导出格式：xls，xlsx

```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Total

2

Last Release

2187d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7ce53eae4a482d22d708c5993346557e49f4adb30fe7dffe1f6a5cac338d2117?d=identicon)[fan1992](/maintainers/fan1992)

---

Top Contributors

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

---

Tags

excelphpphpspreadsheet

### Embed Badge

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

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

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[phpoffice/phppresentation

PHPPresentation - Read, Create and Write Presentations documents in PHP

1.4k2.4M25](/packages/phpoffice-phppresentation)[kartik-v/yii2-export

A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.)

1623.1M35](/packages/kartik-v-yii2-export)[moonlandsoft/yii2-phpexcel

Exporting PHP to Excel or Importing Excel to PHP

1491.1M16](/packages/moonlandsoft-yii2-phpexcel)[yidas/phpspreadsheet-helper

PHP Excel Helper - Write and read Spreadsheet with easy way based on PhpSpreadsheet

383144.5k3](/packages/yidas-phpspreadsheet-helper)[yectep/phpspreadsheet-bundle

A Symfony bundle to integrate with PHPOffice's PhpSpreadsheet library

562.3M4](/packages/yectep-phpspreadsheet-bundle)

PHPackages © 2026

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