PHPackages                             aoding9/dcat-xlswriter-export - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. aoding9/dcat-xlswriter-export

ActiveLibrary[File &amp; Storage](/categories/file-storage)

aoding9/dcat-xlswriter-export
=============================

xlswriter导出excel（dcat-admin扩展）

1.2.3(2y ago)91221MITPHPPHP &gt;=7.1.0

Since Jun 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/aoding9/dcat-xlswriter-export)[ Packagist](https://packagist.org/packages/aoding9/dcat-xlswriter-export)[ RSS](/packages/aoding9-dcat-xlswriter-export/feed)WikiDiscussions master Synced 1mo ago

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

简介
--

[](#简介)

dcat扩展：xlswriter导出

之前用了laravel-excel做数据导出，很耗内存速度也慢，数据量大的时候内存占用容易达到php上限，或者响应超时，换成xlswriter这个扩展来做。

由于直接导出的表格不太美观，经常需要进行合并单元格和自定义表格样式等操作，我对此进行了一些封装，使用更加方便直观。

本扩展是[laravel-xlswriter-export](https://github.com/aoding9/laravel-xlswriter-export) 的dcat版本，使用文档直接看laravel-xlswriter-export的readme即可，此处只介绍不同点。

安装
--

[](#安装)

首先按文档把xlswriter扩展安装上

在phpinfo中确认安装成功后，进行下一步

`composer require aoding9/dcat-xlswriter-export`

国内composer镜像如果安装失败，请设置官方源

`composer config -g repo.packagist composer https://packagist.org`

官方源下载慢，国内镜像偶尔出问题可能导致安装失败，也可以把以下代码添加到composer.json，直接从github安装

如果无法访问github,可以将url改为gitee：`https://gitee.com/aoding9/dcat-xlswriter-export`

```
{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/aoding9/dcat-xlswriter-export"
    }
  ]
}
```

使用
--

[](#使用)

### 1.定义导出类

[](#1定义导出类)

和laravel-xlswriter-export相同，不同点在于，不传参数将使用dcat中grid的查询构造器作为数据源，另外由于make方法与dcat不兼容，只能使用new的方式。

### 2、在控制器中使用

[](#2在控制器中使用)

在grid方法中使用`$grid->export(new UserExport());`即可

由于构造函数传参为空，数据源为other类型，走`buildDataFromOther`获取grid数据，如有特殊需要，可以重写该方法修改获取到的数据

```
//use xxx

protected function grid() {
    return Grid::make(new User(), function(Grid $grid) {
         $grid->export(new UserExport());
        //$grid->export(new UserMergeExport());
    });
}
```

### 3、通过swoole使用

[](#3通过swoole使用)

由于swoole中不能调用`exit()`方法，需要在控制器中直接return下载响应

为此，需要在导出类中将`$useSwoole`属性设为true,然后在dcat控制器中引入`HandleExportIfUseSwoole`，这个trait将重写index方法，以正确地触发下载

```
// UserExport中添加
public $useSwoole = true;

// UserController中添加
use Aoding9\Dcat\Xlswriter\Export\HandleExportIfUseSwoole;
```

版本更新
----

[](#版本更新)

- v1.2.2 (2023-9-16)
    - download时调用`$this->useSwoole()`判断是否使用了swoole，如果使用了，将返回下载响应，代替默认的exit()
    - 新增`HandleExportIfUseSwoole`，用于swoole访问dcat时，重写控制器的index以返回下载响应

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

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

Total

5

Last Release

940d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8e5e1e3041c8541f3a449f0d82e32daa0dd3cd5b6b2d9eccb6c32a1229c4b1d2?d=identicon)[aoding9](/maintainers/aoding9)

---

Top Contributors

[![aoding9](https://avatars.githubusercontent.com/u/65276046?v=4)](https://github.com/aoding9 "aoding9 (22 commits)")

### Embed Badge

![Health badge](/badges/aoding9-dcat-xlswriter-export/health.svg)

```
[![Health](https://phpackages.com/badges/aoding9-dcat-xlswriter-export/health.svg)](https://phpackages.com/packages/aoding9-dcat-xlswriter-export)
```

###  Alternatives

[overtrue/laravel-filesystem-qiniu

A Qiniu storage filesystem for Laravel.

482229.7k16](/packages/overtrue-laravel-filesystem-qiniu)[rahulhaque/laravel-filepond

Use FilePond the Laravel way

261114.4k2](/packages/rahulhaque-laravel-filepond)[overtrue/laravel-filesystem-cos

A Cos storage filesystem for Laravel.

92128.4k7](/packages/overtrue-laravel-filesystem-cos)

PHPackages © 2026

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