I used phpExcel to export the membership table to the browser. The offline test was normal and it can be exported without coding errors.
1. The table is exported normally offline
2. Export the problematic form online
3, after modifying the suffix, garbled characters appear
Now paste the code .
case 'test':
$data1 = MySql::fetchAll("SELECT real_name,telephone,car_id,regtime,endtime,sale,re_tel,type FROM `pw_member` where type= 1");
$data2 = MySql::fetchAll("SELECT real_name,telephone,car_id,regtime,endtime,sale,re_tel,type FROM `pw_member` where type=2");
$data3 = MySql::fetchAll("SELECT real_name,telephone,car_id,regtime,endtime,sale,re_tel,type FROM `pw_member` where type=3");
//3 membership types
foreach($data1 as $key=>&$val){
if($val['type']== 1){
$val['type']='Ordinary member';
}
if($val['regtime']>58001){
$val['regtime']=date('Y-m-d',$val['regtime']);
}
if($val['endtime ']>58001){
$val['endtime']=date('Y-m-d',$val['endtime']);
}
}
foreach($data2 as $key=>&$val){
if($val['type'] ==2){
$val['type']='VIP member';
}
if($val['regtime']>58001) {
$val['regtime']=date('Y-m-d',$val['regtime']);
}
if($val[ 'endtime']>58001){
$val['endtime']=date('Y-m-d',$val['endtime']);
}
}
foreach($data3 as $key=>&$val){
if($val['type ']==3){
$val['type']='Gold Member';
}
if($val['regtime']> ;58001){
$val['regtime']=date('Y-m-d',$val['regtime']);
}
if( $val['endtime']>58001){
$val['endtime']=date('Y-m-d',$val['endtime']);
}
}
// Cxt::dump($data1);
$a=array(
0=>'Real Name',
1=>'Phone number',
2=>'License plate number',
3=>'Registration date',
4=>'Expiry time',
5=>'Recommender',
6=>'Recommender's phone number',
7=>'Member Type',
);
array_unshift($data1,$a); //Add header
array_unshift($data2 ,$a); //Add header
array_unshift($data3,$a); //Add header
$data[1]=$data1;
$data[2]=$data2;
$data[3]=$data3;
require('./include/PHPExcel/PHPExcel.php');
// require dirname(__FILE__).'/PHPExcel/PHPExcel.php';
$objPHPExcel = new PHPExcel();//Instantiate the phpexcel class
// Cxt:: dump($objPHPExcel);
for($i=1;$i<=3;$i ){
if($i>1){
$ objPHPExcel->createSheet();//Create a new built-in table
$objPHPExcel->setActiveSheetIndex($i-1);//Set the newly created sheet as the currently active sheet
}
$objSheet=$objPHPExcel->getActiveSheet();//Get the current active sheet
$objSheet->setTitle($i.'Member');
$objSheet->fromArray($data[$i]);
}
$objWriter=PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$name=date('Y-m-d',time()).time();
$name='member'.$name.'.xlsx ';
// $objWriter->save($name);//Save to server
// header('Content-Type: application/vnd.ms-excel') ;//Tell the browser to output the 2003 file
header('Content-Type: application/vnd.ms-excel; charset=UTF-8');
header('Content- Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8');
header('Content-Disposition: attachment;filename='."$name");//Tell the browser the name of the output file
header('Cache-Control: max-age =0');
$objWriter->save("php://output");
break;
Encountered I would like to give my younger brother some guidance on this issue, and I would like to express my gratitude...
I Know H.T.M.L(How to Meet Ladies)