数据库的格式:
后台:
需求:将用户导到excel表中
//将用户导出到excel表中,并保存用户头像
public function export(){
$exportId = json_decode(Request::param('exportId'),true);//需要导出数据的id
$exportS = Db::name('member');//表名
$objPHPExcel = new PHPExcel();
$objActSheet = $objPHPExcel->getActiveSheet();
try {
$objActSheet->setCellValue( 'A1','用户名' );
$objActSheet->setCellValue( 'B1','电话' );
$objActSheet->setCellValue( 'C1','用户类型' );
$objActSheet->setCellValue( 'D1','性别' );
$objActSheet->setCellValue( 'E1','学校' );
$objActSheet->setCellValue( 'F1','班级' );
$objActSheet->setCellValue( 'G1','地址' );
$objActSheet->setCellValue( 'H1','注册时间' );
$objActSheet->setCellValue( 'I1','头像' );
$objActSheet->setCellValue( 'J1','头像链接' );
$cell_counter = 1;
if( $exportId == null){
$store_ids = $exportS->select();
}else{
$store_ids = $exportS->where('id','in',$exportId)->select();
}
foreach ($store_ids as $shopinfo) {
switch ($shopinfo['user_type']) {
case 1:
$sho