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

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

utf6/phalapi-excel
==================

PahlApi2.x 接口框架利用 PHPExcel 处理Excel 文件

v1.2.1(5y ago)11351MITPHPPHP &gt;=5.2

Since Oct 13Pushed 5y ago1 watchersCompare

[ Source](https://github.com/utf6/phalapi-excel)[ Packagist](https://packagist.org/packages/utf6/phalapi-excel)[ Docs](http://www.phalapi.net)[ RSS](/packages/utf6-phalapi-excel/feed)WikiDiscussions master Synced 4d ago

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

PahlApi2.x 接口框架利用 PHPExcel 处理 Excel 文件

### 附上:

[](#附上)

PhalApi 官网地址： [http://www.phalapi.net/](http://www.phalapi.net/ "PhalApi官网")

### 1、安装

[](#1安装)

可以直接在 composer.json 文件中添加

```
"require": {
    "utf6/phalapi-excel" : "*"
},

```

或者直接使用 composer 安装

```
composer require utf6/phalapi-excel

```

### 2、初始化

[](#2初始化)

在 di.php 加入

```
$di->excel = function() {
    return new \utf6\phalapiExcel\Lite();
};

```

### 3、使用

[](#3使用)

PhalApi-PHPExcel 提供两个基础封装好的方法分别是 `exportExcel` 、`importExcel` 分别处理导入、导出功能。

exportExcel 接受4个参数，`$data` 基础数据，`$headArr`：标题，`$filename` ：文件名称，`$type` ：下载方式（默认 vnd.ms-excel，ajax 导出时为：json）。

下面是一个例子

```
$data = [
    ['name' => '张三', 'password' => 'qwa3la'],
    ['name' => '李四', 'password' => 'vdf45s']
];

$filename    = "用户信息.xlsx";
$headArr     = array("用户名", "密码");

\PhalApi\DI()->excel->exportExcel($filename, $data, $headArr, 'json');
```

PhalApi-PHPExcel 可根据导出的文件后缀来导出不同格式的Excel文档

importExcel 接受三个参数：$filename 文件名称，$keys 键名(选默为空， 可接受一个数组（比如数据库字段名）)，$Sheet 工作表(默认第一张工作表)

```
$data = \PhalApi\DI()->excel->importExcel("./test.xlsx");
//返回
$data = [
    [
        '张三',
        '男'
    ]
];
```

传递键名

```
$keys = ['name', 'sex'];
$data = \PhalApi\DI()->excel->importExcel("./test.xlsx", $keys);
//返回
$data = [
    [
        'name' => '张三',
        'sex' => '男'
    ]
];
```

当然 PHPExcel 是一个强大的工具可以通过 `$PHPExcel->getPHPExcel()` 获得完整的 PHPExcel 实例自由使用！

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

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

4

Last Release

2040d ago

PHP version history (2 changes)v1.0.0PHP ^5.2

v1.2.1PHP &gt;=5.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/14145614?v=4)[utf6](/maintainers/utf6)[@utf6](https://github.com/utf6)

---

Top Contributors

[![daobas](https://avatars.githubusercontent.com/u/185690854?v=4)](https://github.com/daobas "daobas (1 commits)")

---

Tags

excelphalapi

### Embed Badge

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

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

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[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)[codemix/yii2-excelexport

A utility to quickly create Excel files from query results or raw data

104378.0k](/packages/codemix-yii2-excelexport)[bfinlay/laravel-excel-seeder

Seed the database with Laravel using Excel, XLSX, XLS, CSV, ODS, Gnumeric, XML, HTML, SLK files

3944.4k](/packages/bfinlay-laravel-excel-seeder)[roromix/spreadsheetbundle

This is a Symfony 7.1+ Bundle helps you to read and write Spreadsheet files (including pdf, xls, xlsx, odt, csv), thanks to the PHPSpreadsheet library

24410.2k1](/packages/roromix-spreadsheetbundle)

PHPackages © 2026

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