laravel-excel maintained by mradang
Last update
2026/05/02 13:49
License
Require
- laravel/framework ^10.0|^11.0|^12.0|^13.0
- phpoffice/phpspreadsheet ^5.7
Last update
2026/05/02 13:49
License
Require
- laravel/framework ^10.0|^11.0|^12.0|^13.0
- phpoffice/phpspreadsheet ^5.7
Last update
2026/03/24 17:03
License
Require
- laravel/framework ^10.0|^11.0|^12.0|^13.0
- phpoffice/phpspreadsheet ^1.20
Last update
2025/03/11 16:35
License
Require
- laravel/framework ^10.0|^11.0|^12.0
- phpoffice/phpspreadsheet ^1.20
Last update
2024/12/12 16:42
License
Require
- laravel/framework ^9.0 || ^10.0
- phpoffice/phpspreadsheet ^1.20
Last update
2024/12/02 17:03
License
Require
- laravel/framework ^9.0 || ^10.0
- phpoffice/phpspreadsheet ^1.20
Last update
2024/03/16 05:01
License
Require
- laravel/framework ^9.0 || ^10.0
- phpoffice/phpspreadsheet ^1.20
Last update
2023/11/02 11:55
License
Require
- laravel/framework ^9.0 || ^10.0
- phpoffice/phpspreadsheet ^1.20
Last update
2023/04/19 14:18
License
Require
- laravel/framework ^9.0 || ^10.0
- phpoffice/phpspreadsheet ^1.20
Last update
2023/04/19 09:01
License
Require
- laravel/framework ^9.0 || ^10.0
- phpoffice/phpspreadsheet ^1.20
Last update
2023/04/12 11:40
License
Require
- laravel/framework ^9.0 || ^10.0
- phpoffice/phpspreadsheet ^1.20
Last update
2023/03/20 17:57
License
Require
- box/spout ^3.3
- laravel/framework ^9.0 || ^10.0
- phpoffice/phpspreadsheet ^1.20
Last update
2022/05/21 13:27
License
Require
- box/spout ^3.1
- laravel/framework ~9.0
- phpoffice/phpspreadsheet ^1.20
Last update
2022/05/06 09:02
License
Require
- box/spout ^3.1
- laravel/framework ~9.0
- phpoffice/phpspreadsheet ^1.20
Last update
2022/05/02 15:03
License
Require
- box/spout ^3.1
- laravel/framework ~9.0
- phpoffice/phpspreadsheet ^1.20
- psr/simple-cache 2.0.0
Last update
2021/12/07 16:59
License
Require
- php ^7.1|^8.0
- box/spout ^3.1
- laravel/framework ~6.0||~7.0||~8.0
- phpoffice/phpspreadsheet ^1.20
laravel-excel
安装
composer require mradang/laravel-excel -vvv
读取
| 编号 | 姓名 | 年龄 |
|---|---|---|
| 1 | 张三 | 21 |
| 2 | 李四 | 22 |
| 3 | 王五 | 23 |
ExcelService::read(
$pathname, // excel 文件绝对路径
1, // 字段名行号
[
// 字段定义
'id' => '编号',
'name' => '姓名',
'age' => '年龄',
],
2, // 数据开始的行号
function (array $cells) {
// 行数据处理函数,每行调用一次
/**
* $cells = [
* 'id' => 1,
* 'name' => '张三',
* 'age' => 21,
* ];
*/
},
);
写入
$values 参数支持类型
- Illuminate\Database\Eloquent\Builder
- Illuminate\Support\Collection
- array
当使用 Builder 类型时,会调用实例的 chunk 方法,分块读取数据
$pathname = ExcelService::write(
'首行通栏标题',
[
// 字段定义
'id' => '编号',
'name' => '姓名',
'age' => '年龄',
],
['id', 'age'], // 数字列
[
// 数据
['id' => 4, 'name' => '赵六', 'age' => 24],
['id' => 5, 'name' => '孙七', 'age' => 25],
['id' => 6, 'name' => '周八', 'age' => 26],
],
function (int $index, $row) {
// 行数据处理函数,每行调用一次,返回字段值数组
return array_values($row);
},
2, // 冻结字段列
);