Skip to content

Commit 1f22604

Browse files
committed
初始化
0 parents  commit 1f22604

File tree

5 files changed

+432
-0
lines changed

5 files changed

+432
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# phpstorm project files
2+
.idea

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2016 Max.wen
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# php-excel
2+
3+
[![Latest Stable Version](https://poser.pugx.org/jianyan74/php-excel/v/stable)](https://packagist.org/packages/jianyan74/php-excel)
4+
[![Total Downloads](https://poser.pugx.org/jianyan74/php-excel/downloads)](https://packagist.org/packages/jianyan74/php-excel)
5+
[![License](https://poser.pugx.org/jianyan74/php-excel/license)](https://packagist.org/packages/jianyan74/php-excel)
6+
7+
## 安装
8+
9+
```
10+
composer require jianyan74/php-excel
11+
```
12+
13+
引入
14+
15+
```
16+
use jianyan74\excel\Excel;
17+
```
18+
19+
## Demo
20+
21+
```
22+
// [名称, 字段名, 类型, 类型规则]
23+
$header = [
24+
['ID', 'id', 'text'],
25+
['手机号码', 'mobile'], // 规则不填默认text
26+
['openid', 'fans.openid', 'text'],
27+
['昵称', 'fans.nickname', 'text'],
28+
['关注/扫描', 'type', 'selectd', [1 => '关注', 2 => '扫描']],
29+
['性别', 'sex', 'function', function($model){
30+
return $model['sex'] == 1 ? '男' : '女';
31+
}],
32+
['创建时间', 'created_at', 'date', 'Y-m-d'],
33+
];
34+
35+
$list = [
36+
[
37+
'id' => 1,
38+
'type' => 1,
39+
'fans' => [
40+
'openid' => '123',
41+
'nickname' => '昵称',
42+
],
43+
'sex' => 1,
44+
'create_at' => time(),
45+
]
46+
];
47+
```
48+
49+
### 导出
50+
51+
```
52+
// 简单使用
53+
return Excel::exportData($list, $header);
54+
55+
// 定制 默认导出xlsx 支持 : xlsx/xls/html/csv
56+
return Excel::exportData($list, $header, '测试', 'xlsx');
57+
58+
// 另外一种导出csv方式
59+
return Excel::exportCsvData($list, $header);
60+
61+
```
62+
63+
### 导入
64+
65+
```
66+
/**
67+
* 导入
68+
*
69+
* @param $filePath 文件路径
70+
* @param int $startRow 开始行数 默认 1
71+
* @return array|bool|mixed
72+
*/
73+
$data = Excel::import($filePath, $startRow);
74+
```
75+
76+
### 问题反馈
77+
78+
在使用中有任何问题,欢迎反馈给我,可以用以下联系方式跟我交流
79+
80+
QQ群:[655084090](https://jq.qq.com/?_wv=1027&k=4BeVA2r)
81+

composer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "jianyan74/php-excel",
3+
"description": "php excel 导入导出",
4+
"keywords": ["excel", "csv", "xlsx", "xls", "html", "jianyan74"],
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "jianyan74"
9+
}
10+
],
11+
"type": "extension",
12+
"require": {
13+
"php": ">=7.0",
14+
"phpoffice/phpspreadsheet": "^1.3"
15+
},
16+
"autoload": {
17+
"psr-4": {
18+
"jianyan\\excel\\": "./src"
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)