Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
fc667db0
Commit
fc667db0
authored
Nov 14, 2018
by
zw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pk
parent
88b0b40f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
0 deletions
+52
-0
RankingList.php
application/index/controller/RankingList.php
+14
-0
ExportExcelUntil.php
application/index/untils/ExportExcelUntil.php
+37
-0
route.php
application/route.php
+1
-0
No files found.
application/index/controller/RankingList.php
View file @
fc667db0
...
@@ -3,6 +3,7 @@ namespace app\index\controller;
...
@@ -3,6 +3,7 @@ namespace app\index\controller;
use
app\index\extend\Basic
;
use
app\index\extend\Basic
;
use
app\index\service\RankingListService
;
use
app\index\service\RankingListService
;
use
app\index\untils\ExportExcelUntil
;
use
think\Request
;
use
think\Request
;
/**
/**
...
@@ -32,4 +33,16 @@ class RankingList extends Basic{
...
@@ -32,4 +33,16 @@ class RankingList extends Basic{
return
$this
->
response
(
"200"
,
"success"
,
$result
);
return
$this
->
response
(
"200"
,
"success"
,
$result
);
}
}
}
}
public
function
exportReport
(){
$params
=
$this
->
params
;
/* $params["position"] = 1;
$this->siteId = 10001;*/
$export
=
new
ExportExcelUntil
();
$result
=
$this
->
service_
->
RankingList
(
$params
[
"position"
],
$this
->
siteId
);
$title
=
[
'经纪人ID'
,
'门店编号'
,
'部门编号'
,
'经纪人姓名'
,
'经纪人电话'
,
'业绩'
];
$export
->
exportTables
(
'PK明细表'
,
$result
,
6
,
'PK明细表'
,
$title
);
return
''
;
}
}
}
\ No newline at end of file
application/index/untils/ExportExcelUntil.php
View file @
fc667db0
...
@@ -46,4 +46,40 @@ class ExportExcelUntil
...
@@ -46,4 +46,40 @@ class ExportExcelUntil
$class_xls
->
writeToStdOut
();
$class_xls
->
writeToStdOut
();
die
;
die
;
}
}
/**
* 导出Excel
*
* @param string $file_name 文件名
* @param array $data 数据
* @param int $field_num 字段数量
* @param string $table_title 表格title
* @param array $title 表格字段
*/
public
function
exportTables
(
string
$file_name
,
array
$data
,
int
$field_num
,
$table_title
=
""
,
array
$title
=
[])
{
$filename
=
$file_name
.
'-'
.
date
(
'YmdHis'
)
.
".xlsx"
;
//设置 header,用于浏览器下载
header
(
'Content-disposition: attachment; filename="'
.
\XLSXWriter
::
sanitize_filename
(
$filename
)
.
'"'
);
header
(
"Content-Type: application/vnd.openXmlFormats-officeDocument.spreadSheetMl.sheet"
);
header
(
'Content-Transfer-Encoding: binary'
);
header
(
'Cache-Control: must-revaLiDate'
);
header
(
'Pragma: public'
);
$class_xls
=
new
\XLSXWriter
();
$styles1
=
array
(
'font'
=>
'Arial'
,
'font-size'
=>
12
,
'font-style'
=>
'bold'
,
'fill'
=>
'#eee'
,
'halign'
=>
'center'
,
'border'
=>
'left,right,top,bottom'
,
'border-style'
=>
'thin'
,
'Valign'
=>
'center'
,
'height'
=>
20
);
foreach
(
$data
as
$k
=>
$v
)
{
$sheet
=
$k
+
1
;
$class_xls
->
writeSheetHeader
(
'Sheet'
.
$sheet
,
[
'string'
],[
'suppress_row'
=>
true
,
'widths'
=>
[
20
,
25
,
20
,
30
,
30
,
20
,
30
,
20
,
30
]]);
$class_xls
->
writeSheetRow
(
'Sheet'
.
$sheet
,
[
$table_title
],[
'height'
=>
32
,
'font-size'
=>
20
,
'font-style'
=>
'bold'
,
'halign'
=>
'center'
,
'valign'
=>
'center'
]);
$class_xls
->
writeSheetRow
(
'Sheet'
.
$sheet
,
$title
,
$styles1
);
foreach
(
$v
as
$key
=>
$item
){
$row_data
=
array_values
(
$item
);
$class_xls
->
writeSheetRow
(
'Sheet'
.
$sheet
,
$row_data
,
[
'height'
=>
16
]);
}
$class_xls
->
markMergedCell
(
'Sheet'
.
$sheet
,
$start_row
=
0
,
$start_col
=
0
,
$end_row
=
0
,
$end_col
=
$field_num
);
}
$class_xls
->
writeToStdOut
();
die
;
}
}
}
\ No newline at end of file
application/route.php
View file @
fc667db0
...
@@ -359,6 +359,7 @@ Route::group('index', [
...
@@ -359,6 +359,7 @@ Route::group('index', [
'getRandKingList'
=>
[
'index/RankingList/getRandKingList'
,
[
'method'
=>
'GET|POST'
]],
//设置角色站点
'getRandKingList'
=>
[
'index/RankingList/getRandKingList'
,
[
'method'
=>
'GET|POST'
]],
//设置角色站点
'exportReport'
=>
[
'index/RankingList/exportReport'
,
[
'method'
=>
'GET|POST'
]],
]);
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment