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

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

businessg/hyperf-excel
======================

Excel 同步/异步智能配置导入导出组件，为 Hyperf 框架提供强大的 Excel 处理能力,支持无限极列头配置,页码、列头、列样式配置。

v1.0.1-beta.1(1mo ago)41↓100%1MITPHPPHP &gt;=8.1CI failing

Since Mar 11Pushed 1mo agoCompare

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

READMEChangelogDependencies (19)Versions (3)Used By (0)

businessg/hyperf-excel
======================

[](#businessghyperf-excel)

Hyperf 框架的 Excel 同步/异步导入导出组件。基于 [businessg/base-excel](https://github.com/businessg/base-excel) 核心库，提供开箱即用的 HTTP 接口自动注册、CLI 命令、进度追踪、消息推送、数据库日志。

---

目录
--

[](#目录)

- [1. 环境要求与安装](#1-%E7%8E%AF%E5%A2%83%E8%A6%81%E6%B1%82%E4%B8%8E%E5%AE%89%E8%A3%85)
- [2. 配置参考](#2-%E9%85%8D%E7%BD%AE%E5%8F%82%E8%80%83)
    - [2.1 excel.php — 组件核心配置](#21-excelphp--%E7%BB%84%E4%BB%B6%E6%A0%B8%E5%BF%83%E9%85%8D%E7%BD%AE)
    - [2.2 excel\_business.php — 业务配置](#22-excel_businessphp--%E4%B8%9A%E5%8A%A1%E9%85%8D%E7%BD%AE)
        - [导出配置项说明](#%E5%AF%BC%E5%87%BA%E9%85%8D%E7%BD%AE%E9%A1%B9%E8%AF%B4%E6%98%8E)
        - [导入配置项说明](#%E5%AF%BC%E5%85%A5%E9%85%8D%E7%BD%AE%E9%A1%B9%E8%AF%B4%E6%98%8E)
- [3. API 接口参考](#3-api-%E6%8E%A5%E5%8F%A3%E5%8F%82%E8%80%83)
- [4. 实现一个「导出」完整流程](#4-%E5%AE%9E%E7%8E%B0%E4%B8%80%E4%B8%AA%E5%AF%BC%E5%87%BA%E5%AE%8C%E6%95%B4%E6%B5%81%E7%A8%8B)
- [5. 实现一个「导入」完整流程](#5-%E5%AE%9E%E7%8E%B0%E4%B8%80%E4%B8%AA%E5%AF%BC%E5%85%A5%E5%AE%8C%E6%95%B4%E6%B5%81%E7%A8%8B)
- [6. 异步导入导出与队列配置](#6-%E5%BC%82%E6%AD%A5%E5%AF%BC%E5%85%A5%E5%AF%BC%E5%87%BA%E4%B8%8E%E9%98%9F%E5%88%97%E9%85%8D%E7%BD%AE)
- [7. 配置类字段与样式参考](#7-%E9%85%8D%E7%BD%AE%E7%B1%BB%E5%AD%97%E6%AE%B5%E4%B8%8E%E6%A0%B7%E5%BC%8F%E5%8F%82%E8%80%83)
    - [7.1 ExportConfig — 导出配置类](#71-exportconfig--%E5%AF%BC%E5%87%BA%E9%85%8D%E7%BD%AE%E7%B1%BB)
    - [7.2 导出 Sheet](#72-%E5%AF%BC%E5%87%BA-sheet)
    - [7.3 导出 Column](#73-%E5%AF%BC%E5%87%BA-column)
    - [7.4 Style — 单元格样式](#74-style--%E5%8D%95%E5%85%83%E6%A0%BC%E6%A0%B7%E5%BC%8F)
    - [7.5 SheetStyle — Sheet 级样式](#75-sheetstyle--sheet-%E7%BA%A7%E6%A0%B7%E5%BC%8F)
    - [7.6 ImportConfig — 导入配置类](#76-importconfig--%E5%AF%BC%E5%85%A5%E9%85%8D%E7%BD%AE%E7%B1%BB)
    - [7.7 导入 Sheet](#77-%E5%AF%BC%E5%85%A5-sheet)
    - [7.8 导入 Column](#78-%E5%AF%BC%E5%85%A5-column)
- [8. 流程图](#8-%E6%B5%81%E7%A8%8B%E5%9B%BE)
- [9. 内置 Demo 配置](#9-%E5%86%85%E7%BD%AE-demo-%E9%85%8D%E7%BD%AE)
- [10. Hyperf 特别注意事项](#10-hyperf-%E7%89%B9%E5%88%AB%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9)

---

1. 环境要求与安装
----------

[](#1-环境要求与安装)

### 1.1 环境要求

[](#11-环境要求)

依赖版本说明PHP&gt;= 8.1Hyperf3.xSwoole&gt;= 5.0Hyperf 运行时Redis 服务任意版本需运行中，用于进度存储和消息队列MySQL5.7+仅 `dbLog.enabled=true` 时需要### 1.2 PHP 扩展

[](#12-php-扩展)

以下 PHP 扩展必须安装并启用：

```
# xlswriter — Excel 读写核心驱动
pecl install xlswriter
# 安装后在 php.ini 中添加：extension=xlswriter

# redis — 进度追踪和消息队列依赖
pecl install redis
# 安装后在 php.ini 中添加：extension=redis

# mbstring — 字符串处理（通常已内置）
# 如未启用：apt install php-mbstring 或 yum install php-mbstring

# swoole — Hyperf 运行时（通常已安装）
pecl install swoole
```

验证扩展已安装：

```
php -m | grep -E "xlswriter|redis|mbstring|swoole"
# 应输出：
# mbstring
# redis
# swoole
# xlswriter
```

### 1.3 安装

[](#13-安装)

```
composer require businessg/hyperf-excel
```

> 组件自带 `ConfigProvider`，Hyperf 安装后自动合并配置，无需手动注册。

### 1.4 依赖组件说明

[](#14-依赖组件说明)

以下 Composer 包由组件自动引入，无需手动安装。但部分包需要**确认已配置**：

依赖包用途需要的配置`businessg/base-excel`核心库（自动安装）无`hyperf/filesystem`导出文件存储需配置 `config/autoload/file.php`，详见下方`hyperf/redis`进度追踪、消息队列需配置 `config/autoload/redis.php``hyperf/async-queue`异步导入导出需配置 `config/autoload/async_queue.php``hyperf/logger`组件日志输出需配置 `config/autoload/logger.php``hyperf/event`路由注册（BootApplication 事件）无需额外配置`hyperf/command`CLI 命令（excel:export / excel:import）无`hyperf/support`工具函数（`\Hyperf\Support\env()` 等）无`league/flysystem`文件系统抽象层（base-excel 依赖）无需额外配置`ramsey/uuid`生成任务 token无**重点检查项：**

**1) Filesystem（文件系统）— 必须配置**

`hyperf/filesystem` 需要配置文件存储。如果项目中尚未配置，需创建 `config/autoload/file.php`：

```
