use PhpOffice\PhpSpreadsheet\IOFactory ;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate ;
use PhpOffice\PhpSpreadsheet\Spreadsheet ;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx ;
$spreadsheet = new Spreadsheet ();
$objSheet = $spreadsheet -> getActiveSheet (); //获取当前操作sheet的对象
$objSheet -> setCellValue ( 'A1' , '团长' )
-> setCellValue ( 'B1' , '申请时间' )
-> setCellValue ( 'C1' , '提现方式' )
-> setCellValue ( 'D1' , '帐号' )
-> setCellValue ( 'E1' , '姓名' )
-> setCellValue ( 'F1' , '电话' )
-> setCellValue ( 'G1' , '提现金额' );
$i = 2 ;
if ( $list ){
foreach ( $list as $key => $val ) {
switch ( $val -> wd_type ){
case '1' :
$wd_type = '微信' ;
break ;
case '2' :
$wd_type = '支付宝' ;
break ;
case '3' :
$wd_type = '银行卡' ;
break ;
}
$objSheet -> setCellValue ( "A" . $i , $val -> leader_name )
-> setCellValue ( "B" . $i , $val -> update_time )
-> setCellValue ( "C" . $i , $wd_type )
-> setCellValue ( "D" . $i , $val -> wd_account )
-> setCellValue ( "E" . $i , $val -> leader_name )
-> setCellValue ( "F" . $i , $val -> wd_phone )
-> setCellValue ( "G" . $i , $val -> money );
$i ++;
}
} else {
$objSheet -> setCellValue ( "A2" , '没有内容' );
}
$title = "提现列表" ;
header ( 'Content-Type: application/vnd.ms-excel' );
header ( 'Content-Disposition: attachment;filename="' . $title . '.xls"' );
header ( 'Cache-Control: max-age=0' );
$writer = new Xlsx ( $spreadsheet );
$writer -> save ( 'php://output' );