Php uses phpexcel to export data. If you don't talk nonsense, simply copy the code as follows: publicfunctionexport_data ($ dataarray () {# code... include_once (APP_PATH.ToolsPHPExcelClassesPHPExcelWrit)
The code is as follows:
Public function export_data ($ data = array ())
{
# Code...
Include_once (APP_PATH. 'tools/PHPExcel/Classes/PHPExcel/Writer/IWriter. php ');
Include_once (APP_PATH. 'tools/PHPExcel/Classes/PHPExcel/Writer/excel5.php ');
Include_once (APP_PATH. 'tools/PHPExcel/Classes/PHPExcel. php ');
Include_once (APP_PATH. 'tools/PHPExcel/Classes/PHPExcel/IOFactory. php ');
$ Obj_phpexcel = new PHPExcel ();
$ Obj_phpexcel-> getActiveSheet ()-> setCellValue ('A1', 'key ');
$ Obj_phpexcel-> getActiveSheet ()-> setCellValue ('b1 ', 'value ');
If ($ data ){
$ I = 2;
Foreach ($ data as $ key => $ value ){
# Code...
$ Obj_phpexcel-> getActiveSheet ()-> setCellValue ('A'. $ I, $ value );
$ I ++;
}
}
$ Obj_Writer = PHPExcel_IOFactory: createWriter ($ obj_phpexcel, 'excel5 ');
$ Filename = "outexcel.xls ";
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-Transfer-Encoding: binary ");
Header ("Last-Modified:". gmdate ("D, d m y h: I: s"). "GMT ");
Header ("Cache-Control: must-revalidate, post-check = 0, pre-check = 0 ");
Header ("Pragma: no-cache ");
$ Obj_Writer-> save ('php: // output ');
}
The export code is as follows: public function export_data ($ data = array () {# code... export de_once (APP_PATH. 'tools/PHPExcel/Classes/PHPExcel/Writ...