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

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

ezijing/hyperf-excel
====================

hyperf excel工具包

V1.1.25(4y ago)63.2k↑138.9%1MITPHPPHP &gt;=7.2

Since Jan 12Pushed 4y ago1 watchersCompare

[ Source](https://github.com/wojiushidashen/hyperf-excel)[ Packagist](https://packagist.org/packages/ezijing/hyperf-excel)[ Docs](https://github.com/wojiushidashen/hyperf-excel)[ RSS](/packages/ezijing-hyperf-excel/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (14)Versions (25)Used By (0)

**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [hyperf-excel](#hyperf-excel)
    - [安装准备](#%E5%AE%89%E8%A3%85%E5%87%86%E5%A4%87)
        - [1、确保在项目中安装了hyperf验证器](#1%E7%A1%AE%E4%BF%9D%E5%9C%A8%E9%A1%B9%E7%9B%AE%E4%B8%AD%E5%AE%89%E8%A3%85%E4%BA%86hyperf%E9%AA%8C%E8%AF%81%E5%99%A8)
        - [2、添加验证中间件 `config/autoload/middlewares.php`](#2%E6%B7%BB%E5%8A%A0%E9%AA%8C%E8%AF%81%E4%B8%AD%E9%97%B4%E4%BB%B6-configautoloadmiddlewaresphp)
        - [3、添加异常处理器 `config/autoload/exceptions.php`](#3%E6%B7%BB%E5%8A%A0%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86%E5%99%A8-configautoloadexceptionsphp)
    - [安装](#%E5%AE%89%E8%A3%85)
        - [1、在项目根目录下执行](#1%E5%9C%A8%E9%A1%B9%E7%9B%AE%E6%A0%B9%E7%9B%AE%E5%BD%95%E4%B8%8B%E6%89%A7%E8%A1%8C)
        - [2、发布配置文件](#2%E5%8F%91%E5%B8%83%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6)
        - [3、配置文件 `config/autoload/excel_plugin.php`](#3%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6-configautoloadexcel_pluginphp)
        - [4、配置异常处理 `app/Exception/Handler/AppExceptionHandler.php`](#4%E9%85%8D%E7%BD%AE%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86-appexceptionhandlerappexceptionhandlerphp)
    - [使用](#%E4%BD%BF%E7%94%A8)
        - [1、导出单个sheet的excel到本地](#1%E5%AF%BC%E5%87%BA%E5%8D%95%E4%B8%AAsheet%E7%9A%84excel%E5%88%B0%E6%9C%AC%E5%9C%B0)
        - [2、从浏览器导出单个sheet的excel](#2%E4%BB%8E%E6%B5%8F%E8%A7%88%E5%99%A8%E5%AF%BC%E5%87%BA%E5%8D%95%E4%B8%AAsheet%E7%9A%84excel)
        - [3、导出多个sheet的excel到本地](#3%E5%AF%BC%E5%87%BA%E5%A4%9A%E4%B8%AAsheet%E7%9A%84excel%E5%88%B0%E6%9C%AC%E5%9C%B0)
        - [4、从浏览器导出多个sheet的excel](#4%E4%BB%8E%E6%B5%8F%E8%A7%88%E5%99%A8%E5%AF%BC%E5%87%BA%E5%A4%9A%E4%B8%AAsheet%E7%9A%84excel)
        - [5、导入单个sheet的excel](#5%E5%AF%BC%E5%85%A5%E5%8D%95%E4%B8%AAsheet%E7%9A%84excel)
            - [测试数据](#%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE)
            - [(1) 本地导入](#1-%E6%9C%AC%E5%9C%B0%E5%AF%BC%E5%85%A5)
                - [代码](#%E4%BB%A3%E7%A0%81)
                - [导入结果](#%E5%AF%BC%E5%85%A5%E7%BB%93%E6%9E%9C)
            - [(2) 接口导入](#2-%E6%8E%A5%E5%8F%A3%E5%AF%BC%E5%85%A5)
                - [请求方式](#%E8%AF%B7%E6%B1%82%E6%96%B9%E5%BC%8F)
                - [请求参数](#%E8%AF%B7%E6%B1%82%E5%8F%82%E6%95%B0)
                - [代码](#%E4%BB%A3%E7%A0%81-1)
                - [导入结果](#%E5%AF%BC%E5%85%A5%E7%BB%93%E6%9E%9C-1)

hyperf-excel
============

[](#hyperf-excel)

安装准备
----

[](#安装准备)

### 1、确保在项目中安装了hyperf验证器

[](#1确保在项目中安装了hyperf验证器)

```
> composer require hyperf/validation -vvv
> php bin/hyperf.php vendor:publish hyperf/translation # 发布 Translation 组件的文件
> php bin/hyperf.php vendor:publish hyperf/validation # 发布验证器组件的文件：
```

### 2、添加验证中间件 `config/autoload/middlewares.php`

[](#2添加验证中间件-configautoloadmiddlewaresphp)

```
