切换导航条
此项目
正在载入...
登录
anyv
/
xkeasy
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
刘朕
3 years ago
提交
aef475cf5054112f8d536030fd53be516914c926
1 个父辈
50e23a35
1 个管道 的构建
通过
耗费 5 秒
数据导出调试
变更
1
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
118 行增加
和
1 行删除
app/portal/controller/TestController.php
app/portal/controller/TestController.php
查看文件 @
aef475c
...
...
@@ -73,6 +73,41 @@ class TestController extends HomeBaseController
print_r
(
$arr
);
exit
;
}
public
function
income
()
{
$uid
=
451
;
$user
=
Db
::
name
(
'user'
)
->
where
(
'id'
,
$uid
)
->
find
();
$indent
=
Db
::
name
(
'money_income'
)
->
where
(
'uid'
,
$uid
)
->
order
(
'create_time'
,
'desc'
)
->
select
();
$arr
=
collection
(
$indent
)
->
toArray
();
$data
=
[];
$tableheader
=
array
(
'收入id'
,
'收入金额'
,
'订单id'
);
foreach
(
$arr
as
&
$v
)
{
$data
[]
=
[
$v
[
'id'
],
$v
[
'money'
],
$v
[
'indent_id'
]
];
}
$this
->
excel2
(
$data
);
print_r
(
$arr
);
exit
;
}
public
function
withdraw_log
()
{
$uid
=
451
;
$money_expend
=
Db
::
name
(
'money_expend'
)
->
where
(
'uid'
,
$uid
)
->
where
(
'state'
,
1
)
->
order
(
'create_time'
,
'desc'
)
->
select
();
$money_expend
=
collection
(
$money_expend
)
->
toArray
();
$data
=
[];
foreach
(
$money_expend
as
$v
)
{
$data
[]
=
[
date
(
'Y-m-d H:i:s'
,
$v
[
'create_time'
]),
$v
[
'money'
]
];
}
$this
->
excel3
(
$data
);
}
/**
*
...
...
@@ -111,6 +146,88 @@ class TestController extends HomeBaseController
//填充表格信息
for
(
$i
=
3
;
$i
<=
count
(
$data2
)
+
1
;
$i
++
)
{
$j
=
0
;
foreach
(
$data2
[
$i
-
3
]
as
$key
=>
$value
)
{
$excel
->
getActiveSheet
()
->
setCellValue
(
"
$letter[$j]$i
"
,
"
$value
"
);
$j
++
;
}
}
//创建Excel输入对象
$write
=
new
\PHPExcel_Writer_Excel2007
(
$excel
);
header
(
"Pragma: public"
);
header
(
"Expires: 0"
);
header
(
"Cache-Control:must-revalidate, post-check=0, pre-check=0"
);
header
(
"Content-Type:application/force-download"
);
header
(
"Content-Type:application/vnd.ms-execl"
);
header
(
"Content-Type:application/octet-stream"
);
header
(
"Content-Type:application/download"
);;
header
(
'Content-Disposition:attachment;filename="订单表.xlsx"'
);
header
(
"Content-Transfer-Encoding:binary"
);
$write
->
save
(
'php://output'
);
}
/**
*
* 导出Excel
*/
public
function
excel2
(
$data2
)
{
//引入PHPExcel库文件
// Vendor('phpexcel2.PHPExcel');
//创建对象
$excel
=
new
\PHPExcel
();
//Excel表格式,这里简略写了8列
$letter
=
array
(
'A'
,
'B'
,
'C'
);
//表头数组
$tableheader
=
array
(
'收入id'
,
'收入金额'
,
'订单id'
);
//填充表头信息
for
(
$i
=
0
;
$i
<
count
(
$tableheader
);
$i
++
)
{
$excel
->
getActiveSheet
()
->
setCellValue
(
"
$letter[$i]
1"
,
"
$tableheader[$i]
"
);
}
//填充表格信息
for
(
$i
=
2
;
$i
<=
count
(
$data2
)
+
1
;
$i
++
)
{
$j
=
0
;
foreach
(
$data2
[
$i
-
2
]
as
$key
=>
$value
)
{
$excel
->
getActiveSheet
()
->
setCellValue
(
"
$letter[$j]$i
"
,
"
$value
"
);
$j
++
;
}
}
//创建Excel输入对象
$write
=
new
\PHPExcel_Writer_Excel2007
(
$excel
);
header
(
"Pragma: public"
);
header
(
"Expires: 0"
);
header
(
"Cache-Control:must-revalidate, post-check=0, pre-check=0"
);
header
(
"Content-Type:application/force-download"
);
header
(
"Content-Type:application/vnd.ms-execl"
);
header
(
"Content-Type:application/octet-stream"
);
header
(
"Content-Type:application/download"
);;
header
(
'Content-Disposition:attachment;filename="收入表.xlsx"'
);
header
(
"Content-Transfer-Encoding:binary"
);
$write
->
save
(
'php://output'
);
}
/**
*
* 导出Excel
*/
public
function
excel3
(
$data2
)
{
//引入PHPExcel库文件
// Vendor('phpexcel2.PHPExcel');
//创建对象
$excel
=
new
\PHPExcel
();
//Excel表格式,这里简略写了8列
$letter
=
array
(
'A'
,
'B'
);
//表头数组
$tableheader
=
array
(
'提现时间'
,
'提现金额'
);
//填充表头信息
for
(
$i
=
0
;
$i
<
count
(
$tableheader
);
$i
++
)
{
$excel
->
getActiveSheet
()
->
setCellValue
(
"
$letter[$i]
1"
,
"
$tableheader[$i]
"
);
}
//填充表格信息
for
(
$i
=
3
;
$i
<=
count
(
$data2
)
+
1
;
$i
++
)
{
$j
=
0
;
foreach
(
$data2
[
$i
-
2
]
as
$key
=>
$value
)
{
$excel
->
getActiveSheet
()
->
setCellValue
(
"
$letter[$j]$i
"
,
"
$value
"
);
$j
++
;
...
...
@@ -125,7 +242,7 @@ class TestController extends HomeBaseController
header
(
"Content-Type:application/vnd.ms-execl"
);
header
(
"Content-Type:application/octet-stream"
);
header
(
"Content-Type:application/download"
);;
header
(
'Content-Disposition:attachment;filename="
信息系统
表.xlsx"'
);
header
(
'Content-Disposition:attachment;filename="
提现
表.xlsx"'
);
header
(
"Content-Transfer-Encoding:binary"
);
$write
->
save
(
'php://output'
);
}
...
...
请
注册
或
登录
后发表评论