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

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

xinqingch/php-excel
===================

php excel 导入导出

1.0.0(1y ago)08MITPHPPHP &gt;=7.0

Since Jul 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/xinqingch/php-excel)[ Packagist](https://packagist.org/packages/xinqingch/php-excel)[ RSS](/packages/xinqingch-php-excel/feed)WikiDiscussions main Synced 1mo ago

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

excel
=====

[](#excel)

Yii2 excel导入导出类 引入

```
use xinqingch\excel\Excel;

```

Demo
----

[](#demo)

```
// [名称, 字段名, 类型, 类型规则]
$header = [
    ['ID', 'id', 'text'],
    ['手机号码', 'mobile'], // 规则不填默认text
    ['openid', 'fans.openid', 'text'],
    ['昵称', 'fans.nickname', 'text'],
    ['关注/扫描', 'type', 'selectd', [1 => '关注', 2 => '扫描']],
    ['性别', 'sex', 'function', function($model){
        return $model['sex'] == 1 ? '男' : '女';
    }],
    ['创建时间', 'created_at', 'date', 'Y-m-d'],
    ['图片', 'image', 'text'],// 本地图片 ./images/765456898612.jpg
];

$list = [
    [
        'id' => 1,
        'type' => 1,
        'mobile' => '18888888888',
        'fans' => [
            'openid' => '123',
            'nickname' => '昵称',
        ],
        'sex' => 1,
        'create_at' => time(),
    ]
];

```

### 导出

[](#导出)

```
// 简单使用
return Excel::exportData($list, $header);

// 定制 默认导出xlsx 支持 : xlsx/xls/html/csv， 支持写入绝对路径
return Excel::exportData($list, $header, '测试', 'xlsx', '/www/data/');

// 另外一种导出csv方式
return Excel::exportCsvData($list, $header);

// 带图片的
* @param array $list   数据
* @param array $header 数据处理格式
* @param string $filename  导出的文件名
* @param string $suffix    导出的格式
* @param string $path      导出的存放地址 无则不在服务器存放
* @param string $image    导出的格式 可以用 大写字母 或者 数字 标识 哪一列
Excel::exportData($list, $header,date('Y-m-d h:i:s'),'xlsx','',['D','E']);
Excel::exportData($list, $header,date('Y-m-d h:i:s'),'xlsx','',[4,5]);

//多工作表导出
//['keyword',50,'FF0000'] 分别代表KEY，单元格宽度，单元格背景色
$header =[
            '关键词'=>['keyword',50,'FF0000'],
            '关键词数量'=>'keynum',
            '数量占比'=>'keynum_rate',
            '关键词流量总和'=>'keysearch',
            '流量占比'=>'keysearch_rate'

        ];
$list = [
    [
        'keyword' => 'keyword name',
        'keynum' => 1,
        'keynum_rate' => '3%',
        'keysearch' => '232',
        'keysearch_rate' => '1%',
    ]
];
$expdata=[];
$expdata[] = $execl->exportLink('关键词词库',$header,$list);//词库数据转换
//多个表可以设置多个$expdata[]即可
/**
 * 导入
 *
 * @param $expdata     生成数据
 * @param $path  保存地址，如空可使用流式直接输出
 * @param $filename  文件名称
 * @param string $suffix    导出的格式 默认支持xlsx,xls,csv
 * @return array|bool|mixed
 */
$execl = new Excel();
$execl->xtExport($expdata,$path,$filename,'xlsx');

```

### 导入

[](#导入)

```
/**
 * 导入
 *
 * @param $filePath     excel的服务器存放地址 可以取临时地址
 * @param int $startRow 开始和行数 默认1
 * @param bool $hasImg  导出的时候是否有图片
 * @param string $suffix    格式
 * @param string $imageFilePath     作为临时使用的 图片存放的地址
 * @return array|bool|mixed
 */
$data = Excel::import($filePath, $startRow = 1,$hasImg = false,$suffix = 'Xlsx',$imageFilePath = null);

```

### 问题反馈

[](#问题反馈)

在使用中有任何问题，欢迎反馈给我，可以用以下联系方式跟我交流 QQ：8818190

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

667d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0aea92195e7281cdcf2b8353756f03d904b0b2fe1f720225e597b1d3991045df?d=identicon)[xinqingch](/maintainers/xinqingch)

---

Top Contributors

[![xinqingch](https://avatars.githubusercontent.com/u/2876261?v=4)](https://github.com/xinqingch "xinqingch (8 commits)")

---

Tags

htmlexcelxlsxlsxcsvmorven

### Embed Badge

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

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

###  Alternatives

[rap2hpoutre/fast-excel

Fast Excel import/export for Laravel

2.3k24.9M47](/packages/rap2hpoutre-fast-excel)[gotenberg/gotenberg-php

A PHP client for interacting with Gotenberg, a developer-friendly API for converting numerous document formats into PDF files, and more!

3685.2M19](/packages/gotenberg-gotenberg-php)[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)[nuovo/spreadsheet-reader

Spreadsheet reader library for Excel, OpenOffice and structured text files

669863.2k8](/packages/nuovo-spreadsheet-reader)[jianyan74/php-excel

php excel 导入导出

5842.2k4](/packages/jianyan74-php-excel)[jgrygierek/batch-entity-import-bundle

Importing entities with preview and edit features for Symfony.

101.1M1](/packages/jgrygierek-batch-entity-import-bundle)

PHPackages © 2026

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