Example code for exporting data in phpexcel
This article introduces a piece of code for php to export data using phpexcel. if you need it, you may wish to make a reference and hope to help you. Use the phpexcel class library to export data. the code is as follows:
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');} // at 11:22:18 |