...
|
...
|
@@ -3,6 +3,7 @@ |
|
|
namespace app\admin\controller\litestore;
|
|
|
|
|
|
use app\admin\model\litestore\Litestoregoodsspec;
|
|
|
use app\api\model\Goods;
|
|
|
use app\common\controller\Backend;
|
|
|
use app\admin\model\litestore\Litestorespec as SpecModel;
|
|
|
use app\admin\model\litestore\Litestorespecvalue as SpecValueModel;
|
...
|
...
|
@@ -272,16 +273,23 @@ class Litestoregoods extends Backend |
|
|
/**
|
|
|
* 导出
|
|
|
*/
|
|
|
public function clubpeople(){
|
|
|
//1.从数据库中导出需要进行要导出的数据
|
|
|
$list =Db::query('SELECT stu_list.stu_name,stu_list.stu_department,stu_list.stu_phone,stu_list.stu_email,stu_list.stu_profess
|
|
|
,club_branch.* FROM club_branch INNER JOIN stu_list ON club_branch.stu_number = stu_list.stu_number
|
|
|
where club_branch.club_id=:acc order by club_branch.club_branch_name ',['acc'=>$clubid]);
|
|
|
|
|
|
|
|
|
public function clubpeople()
|
|
|
{
|
|
|
//1.从数据库中导出需要进行要导出的数据
|
|
|
// $list = Db::query('SELECT stu_list.stu_name,stu_list.stu_department,stu_list.stu_phone,stu_list.stu_email,stu_list.stu_profess
|
|
|
// ,club_branch.* FROM club_branch INNER JOIN stu_list ON club_branch.stu_number = stu_list.stu_number
|
|
|
// where club_branch.club_id=:acc order by club_branch.club_branch_name ', ['acc' => $clubid]);
|
|
|
$goods = new Goods();
|
|
|
$list = $goods->select()->each(function (&$item){
|
|
|
// $;
|
|
|
});
|
|
|
if (empty($list)){
|
|
|
$this->error('没有可导出的数据');
|
|
|
}
|
|
|
// foreach ()
|
|
|
|
|
|
|
|
|
//重要补助
|
|
|
//重要补助
|
|
|
//2.加载PHPExcle类库
|
|
|
vendor('PHPExcel.PHPExcel');
|
|
|
//3.实例化PHPExcel类
|
...
|
...
|
@@ -308,29 +316,29 @@ class Litestoregoods extends Backend |
|
|
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setWidth(20);
|
|
|
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setWidth(30);
|
|
|
|
|
|
for($i=0;$i<count($list);$i++){
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('A'.($i+2),$list[$i]['club_branch_name']);//ID
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('B'.($i+2),$list[$i]['club_position']);//标签码
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('C'.($i+2),$list[$i]['stu_number']);//防伪码
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('D'.($i+2),$list[$i]['stu_name']);//ID
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E'.($i+2),$list[$i]['stu_phone']);//标签码
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('F'.($i+2),$list[$i]['stu_email']);//ID
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('G'.($i+2),$list[$i]['stu_department']);//标签码
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('H'.($i+2),$list[$i]['stu_profess']);//防伪码
|
|
|
for ($i = 0; $i < count($list); $i++) {
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $list[$i]['club_branch_name']);//ID
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $list[$i]['club_position']);//标签码
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $list[$i]['stu_number']);//防伪码
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $list[$i]['stu_name']);//ID
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $list[$i]['stu_phone']);//标签码
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $list[$i]['stu_email']);//ID
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('G' . ($i + 2), $list[$i]['stu_department']);//标签码
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('H' . ($i + 2), $list[$i]['stu_profess']);//防伪码
|
|
|
}
|
|
|
//7.设置保存的Excel表格名称
|
|
|
$filename = $club_name.'人员名单'.date('ymd',time()).'.xls';
|
|
|
$filename = $club_name . '人员名单' . date('ymd', time()) . '.xls';
|
|
|
//8.设置当前激活的sheet表格名称;
|
|
|
$objPHPExcel->getActiveSheet()->setTitle('人员名单');
|
|
|
//9.设置浏览器窗口下载表格
|
|
|
header("Content-Type: application/force-download");
|
|
|
header("Content-Type: application/octet-stream");
|
|
|
header("Content-Type: application/download");
|
|
|
header('Content-Disposition:inline;filename="'.$filename.'"');
|
|
|
header('Content-Disposition:inline;filename="' . $filename . '"');
|
|
|
//生成excel文件
|
|
|
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
|
|
//下载文件在浏览器窗口
|
|
|
$objWriter->save('php://output');
|
|
|
exit;
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|