First paste the code: {code...} to export the following error:
Post Code first:
Public function check_daochu ($ data) {$ this-> load-> library ('phpexcel '); $ this-> load-> library ('phpexcel/IOFactory '); $ objPHPExcel = new PHPExcel (); $ objWriter = new PHPExcel_Writer_Excel2007 ($ objPHPExcel); // set the header $ this-> Excel_bt ($ objPHPExcel, $ data ['bt _ data']); // exported class capacity $ this-> Excel_lr ($ objPHPExcel, $ data ['data']); // set the cell width $ objPHPExcel-> getActiveSheet ()-> getColumnDimension ('B')-> setWidth (15 ); foreach ($ data ['hb _ data'] as $ key => $ value) {// merge cells $ objPHPExcel-> getActiveSheet ()-> mergeCells ($ key. ':'. $ value);} // horizontal vertical center setting $ objPHPExcel-> getActiveSheet ()-> getStyle ('a1')-> getAlignment ()-> setVertical (PHPExcel_Style_Alignment :: VERTICAL_CENTER); $ objPHPExcel-> getActiveSheet ()-> getStyle ('a1')-> getAlignment ()-> setHorizontal (PHPExcel_Style_Alignment: HORIZONTAL_CENTER ); $ fieldname = iconv ('utf-8', 'gb2312', date ("Y-m-d", time ()). '_'. $ data ['bt _ data'] ['a1']); ob_end_clean (); header ("Pragma: public"); header ("Expires: 0 "); header ("Cache-Control: must-revalidate, post-check = 0, pre-check = 0"); header ("Content-Type: application/force-download "); header ("Content-Type: application/vnd. ms-execl "); header (" Content-Type: application/octet-stream "); header (" Content-Type: application/download "); header ('content-Disposition: attachment; filename = "'. $ fieldname. '.xlsx "'); header (" Content-Transfer-Encoding: binary "); $ objWriter-> save ('php: // output ');} // set the export title to public function Excel_bt ($ objPHPExcel, $ bt_data) {foreach ($ bt_data as $ key => $ value) {$ objPHPExcel-> getActiveSheet () -> setCellValue ($ key, $ value) ;}// set the exported public function Excel_lr ($ objPHPExcel, $ select_data) {$ I = 3; $ data = array ('A', 'B', 'C', 'D', 'E', 'E', 'F', 'G', 'h ', 'I', 'J', 'k', 'l', 'M', 'n', 'O', 'P', 'Q', 'R ', 'S ', 't', 'U', 'V', 'w', 'x', 'y', 'z '); foreach ($ select_data as $ key = >$ value) {$ j = 0; foreach ($ value as $ k = >$ v) {$ objPHPExcel-> getActiveSheet () -> setCellValue ($ data [$ j]. $ I, $ v); $ j ++;} $ I ++ ;}}
The following error occurs during export:
Reply content:
Post Code first:
Public function check_daochu ($ data) {$ this-> load-> library ('phpexcel '); $ this-> load-> library ('phpexcel/IOFactory '); $ objPHPExcel = new PHPExcel (); $ objWriter = new PHPExcel_Writer_Excel2007 ($ objPHPExcel); // set the header $ this-> Excel_bt ($ objPHPExcel, $ data ['bt _ data']); // exported class capacity $ this-> Excel_lr ($ objPHPExcel, $ data ['data']); // set the cell width $ objPHPExcel-> getActiveSheet ()-> getColumnDimension ('B')-> setWidth (15 ); foreach ($ data ['hb _ data'] as $ key => $ value) {// merge cells $ objPHPExcel-> getActiveSheet ()-> mergeCells ($ key. ':'. $ value);} // horizontal vertical center setting $ objPHPExcel-> getActiveSheet ()-> getStyle ('a1')-> getAlignment ()-> setVertical (PHPExcel_Style_Alignment :: VERTICAL_CENTER); $ objPHPExcel-> getActiveSheet ()-> getStyle ('a1')-> getAlignment ()-> setHorizontal (PHPExcel_Style_Alignment: HORIZONTAL_CENTER ); $ fieldname = iconv ('utf-8', 'gb2312', date ("Y-m-d", time ()). '_'. $ data ['bt _ data'] ['a1']); ob_end_clean (); header ("Pragma: public"); header ("Expires: 0 "); header ("Cache-Control: must-revalidate, post-check = 0, pre-check = 0"); header ("Content-Type: application/force-download "); header ("Content-Type: application/vnd. ms-execl "); header (" Content-Type: application/octet-stream "); header (" Content-Type: application/download "); header ('content-Disposition: attachment; filename = "'. $ fieldname. '.xlsx "'); header (" Content-Transfer-Encoding: binary "); $ objWriter-> save ('php: // output ');} // set the export title to public function Excel_bt ($ objPHPExcel, $ bt_data) {foreach ($ bt_data as $ key => $ value) {$ objPHPExcel-> getActiveSheet () -> setCellValue ($ key, $ value) ;}// set the exported public function Excel_lr ($ objPHPExcel, $ select_data) {$ I = 3; $ data = array ('A', 'B', 'C', 'D', 'E', 'E', 'F', 'G', 'h ', 'I', 'J', 'k', 'l', 'M', 'n', 'O', 'P', 'Q', 'R ', 'S ', 't', 'U', 'V', 'w', 'x', 'y', 'z '); foreach ($ select_data as $ key = >$ value) {$ j = 0; foreach ($ value as $ k = >$ v) {$ objPHPExcel-> getActiveSheet () -> setCellValue ($ data [$ j]. $ I, $ v); $ j ++;} $ I ++ ;}}
The following error occurs during export:
What does your failure mean?
register_shutdown_function(function(){ $lastError = error_get_last(); if ($lastError) { error_log(json_encode($lastError)); }});
Open it in notepad to see if there is any error.
Generally, this is an error.
I still cannot find the reason for my previous post.