PHPackages                             tiderjian/qs-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. tiderjian/qs-excel

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

tiderjian/qs-excel
==================

qs excel helper

v1.3.7(4y ago)03.0k12MITPHPPHP &gt;=7.2.0

Since Dec 10Pushed 4y ago1 watchersCompare

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

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

### 安装

[](#安装)

```
composer require tiderjian/qs-excel
```

### 介绍

[](#介绍)

Excel文件生成及Excel文件读取

### 用法

[](#用法)

#### ListBuilder

[](#listbuilder)

- 生成单个sheet的excel文件

```
$options  = [
    'row_count' => 500,    //excel生成的行数
    'headers' => [
        [
            'title' => '读者编号',
        ],
        [
            'title' => '姓名',
        ],
        [
            'title' => '性别',
            'type' => 'list',
            'data_source' => '女,男'
        ],
        [
            'title' => '读者类型',
            'type' => 'list',
            'data_source' => '高年级学生,低年级学生,老师'
        ],
        [
            'title' => '读者状态',
            'type' => 'list',
            'data_source' => '停用,正常,注销,挂失'
        ],
        [
            'title' => '注册日期'
        ],
        [
            'title' => '学号'
        ]
    ]
];

//列表数据
//次序与类型必须与options对应
$data = [
    'DD123456',
    '张三',
    '女',
    '高年级学生',
    '停用',
    '2016-07-10',
    'G44532220060903492X'
];
$excel = new \QsExcel\Excel();
$excel->addBuild(new \QsExcel\Builder\ListBuilder($options, $data));
$excel->output('reader_import.xlsx');
```

- 生成多个sheet的excel文件

```
//大数组数据，总字符串长度超过565，将会自动生成数据源sheet进行存储
$project_arrs = [
    .
    .
    .
];

$book_arrs = [
    .
    .
    .
];

$options  = [
    'row_count' => 500,
    'headers' => [
        [
            'title' => '读者编号',
        ],
        [
            'title' => '姓名',
        ],
        [
            'title' => '性别',
            'type' => 'list',
            'data_source' => '女,男'
        ],
        [
            'title' => '项目',
            'type' => 'list',
            'data_source' => implode(',', $project_arrs)
        ],
        [
            'title' => '推荐书籍',
            'type' => 'list',
            'data_source' => implode(',', $book_arrs)
        ],
        [
            'title' => '注册日期'
        ],
        [
            'title' => '学号'
        ]
    ]
];

$options1  = [
    'row_count' => 500,
    'headers' => [
        [
            'title' => '读者姓名',
        ],
        [
            'title' => '学校',
        ],
        [
            'title' => '性别',
            'type' => 'list',
            'data_source' => '女,男'
        ],
        [
            'title' => '项目',
            'type' => 'list',
            'data_source' => implode(',', $project_arrs)
        ],
        [
            'title' => '注册日期'
        ],
        [
            'title' => '学号'
        ]
    ]
];

$excel = new \QsExcel\Excel();
$excel->addBuild((new \QsExcel\ListBuilder($options))->setSheetName('test'));
$excel->addBuild((new \QsExcel\ListBuilder($options1))->setSheetName('test1'));
$excel->output('reader_import.xlsx');
```

##### Cell Type

[](#cell-type)

- ListTypeBuilder 将单元格设置成下拉列表,支持三种设置数据源的方式

> 1. 短字符串
>
> > 短字符串的含义是小于565个字符，此时短字符串会直接设置为列表数据源，不会有额外的表格内容占用, 内容用","分隔。

```
[
    'title' => '性别',
    'type' => QsExcel\Builder\ListBuilder::LIST_TYPE,
    'data_source' => '男,女'
];
```

> 2. 长字符串
>
> > 长字符串是相对于短字符串而言的，也就是大于565个字符，此时qs-excel会自动生成一个名字为ListSource的sheet用于存放数据源

```
$arr = []; //大数组
[
    'title' => '性别',
    'type' => QsExcel\Builder\ListBuilder::LIST_TYPE,
    'data_source' => implode(',', $arr)
];
```

> 3. 指定引用源
>
> > qs-excel 支持以 "sheet!$A$1:$A$20" 这种格式的方式设置任意表格的引用数据源

```
[
    'title' => '团队名',
    'type' => QsExcel\Builder\ListBuilder::LIST_TYPE,
    'data_source' => '团队信息!$B$2:$B$500'   // 团队信息为其他sheet的sheet名，前后两个列字母的必须一致，这个例子就是B
];
```

- DateTypeBuilder 将单元格设置成日期格式

```
[
    'title' => '出生日期',
    'type' => QsExcel\Builder\ListBuilder::DATE_TYPE
];
```

- MultiListTypeBuilder 多选类型

    该类型不会对数据进行准确性校验，只会在ListSource sheet增加可选的值

```
$arr = [ '标签1', '标签2', ...];
[
    'title' => '标签',
    'type' => QsExcel\Builder\ListBuilder::MULTI_LIST_TYPE,
    'data_source' => implode(',', $arr)
];
```

#### ListLoader

[](#listloader)

```
$file = __DIR__ . '/excel.xls';
$excel = new Excel();
//需要读取多少个sheet的数据，则设置多少个loader，可根据不同的sheet类型来针对性的设置不同的loader类型
//默认第一个loader读取index为0的sheet 第二个读取index为1的sheet，以此类推
$excel->setLoadFile($file);
$excel->addLoader(new ListLoader());
$excel->addLoader(new ListLoader());
$excel->addLoader(new ListLoader());
$excel->addLoader(new ListLoader());
$list = $excel->load();
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% 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 ~66 days

Recently: every ~129 days

Total

14

Last Release

1481d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/15a0610fee78753bdad92fd45c3506455c0fd45ae51924797b1841d260495a3f?d=identicon)[tiderjian](/maintainers/tiderjian)

---

Top Contributors

[![Xhiny](https://avatars.githubusercontent.com/u/35066497?v=4)](https://github.com/Xhiny "Xhiny (6 commits)")[![tiderjian](https://avatars.githubusercontent.com/u/1665649?v=4)](https://github.com/tiderjian "tiderjian (4 commits)")

---

Tags

excelphpspreadsheet

### Embed Badge

![Health badge](/badges/tiderjian-qs-excel/health.svg)

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

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M708](/packages/maatwebsite-excel)[yidas/phpspreadsheet-helper

PHP Excel Helper - Write and read Spreadsheet with easy way based on PhpSpreadsheet

383144.5k3](/packages/yidas-phpspreadsheet-helper)

PHPackages © 2026

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