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

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

bean/excel
==========

This package help you to import Excel and export Excel

1.1(8y ago)1346[1 issues](https://github.com/bean-du/excel/issues)MITPHPPHP ^5.3.3 || ^7.0

Since Sep 19Pushed 8y ago1 watchersCompare

[ Source](https://github.com/bean-du/excel)[ Packagist](https://packagist.org/packages/bean/excel)[ Docs](https://github.com/bean-du/excel)[ RSS](/packages/bean-excel/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

#### bean/excel

[](#beanexcel)

> 这是一个Excel处理包，包含了ExcelReader和ExcelWriter、Helpers类，帮助你处理基本的Excel操作。

`ExcelReander` 类包主要负责读取Excel，智能的识别文件类型和读取文件，让你不在为导入的文件类型而烦恼，目前支持的格式有：`xlsx` ,`xls`,`csv` 。也就是说目前支持excel97-excel2003，excel2007和csv格式。

### 特性 :

[](#特性-)

1. 自动判断传入文件类型
2. 支持excel日期格式
3. 支持公式计算值
4. 支持自定义获取数据

### 使用实例 :

[](#使用实例-)

```
   use Excel/ExcelReader;
   // 实例化ExcelReader类
   $reader = new ExcelReader($realPath);
   // 粗暴的获取Excel数据
   $data = $reader->readExcel()->readSheet()->getData();
   // 也可以这样使用
   $excel = $reader->readExcel();
   $sheetNumber = $excel->sheetNumber;
   $sheetName = $excel->sheetName[0];
   $sheet = $excel->readSheet($sheetName);
   $columnCount = $sheet->column;
   $rowCount = $sheet->row;
   $data = $sheet->getData()
```

`ExcelWriter` 是Excel导出类

### 特性 :

[](#特性--1)

1. 支持写入`xslx` `xls` `csv`格式
2. 支持设置字体颜色
3. 支持设置单元格背景颜色
4. 支持设置单元格宽度（指定和自适应）
5. 支持合并单元格
6. 支持设置单元格对齐方式（水平、垂直）
7. 支持多sheet操作
8. 支持保存文件和浏览器输出

### 使用实例 :

[](#使用实例--1)

```
    $writer = new ExcelWriter();

    for ($i = 0; $i < 100; $i++){
        for ($j = 0; $j < 10; $j++){
            $data[$i][$j] = 'test ['.$i.']+['.$j.']';
        }
    }
    $writer->setWidth(range('A','J'))
        ->setValue($data)
        ->setFormat('xls')
        ->setAlignment(array('A1','C1'),'CENTER')
        ->setBackgroundColor(array('A1','C1'),'#ccccc')
        ->setAlignment(array('A2','C2'),'RIGHT')
        ->setActiveSheetName('Bean')
        ->outPut('test.xls');
```

> 为了方便上传的同学，提供一个Helpers上传文件类。

### 使用实例 :

[](#使用实例--2)

```
    $help = new Helpers();
    if ($help->hasFile('file')){
        $file = $help->uploadFile('file');
        $fileExtension = $file->fileExtension();
        $fileName = $file->fileName();
        $fileSize = $file->fileSize();
        $fileMineType = $file->fileMineType();
    }else{
        echo '文件上传失败';
    }
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

3204d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10751822?v=4)[acorn](/maintainers/bean-du)[@bean-du](https://github.com/bean-du)

---

Top Contributors

[![bean-du](https://avatars.githubusercontent.com/u/10751822?v=4)](https://github.com/bean-du "bean-du (11 commits)")

---

Tags

excel

### Embed Badge

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

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

###  Alternatives

[liuggio/excelbundle

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

3786.4M11](/packages/liuggio-excelbundle)[wisembly/excelant

69159.0k](/packages/wisembly-excelant)[arogachev/yii2-excel

ActiveRecord import and export based on PHPExcel for Yii 2 framework

6381.0k1](/packages/arogachev-yii2-excel)[dakota/cake-excel

CakePHP excel generator

2325.1k](/packages/dakota-cake-excel)[phpnt/yii2-export

Yii2 It saves data in xls, csv, word, html, pdf files.

158.9k](/packages/phpnt-yii2-export)[akeneo-labs/excel-connector-bundle

Akeneo PIM Excel connector bundle

166.4k](/packages/akeneo-labs-excel-connector-bundle)

PHPackages © 2026

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