To export the content in the mysql database to excel, you only need to use the header to output the csv format document, you can simply export the excel file in mysql. let's take a look at the example below. the core code is here. the code is as follows: heade... to export the content in the mysql database to excel, you only need to use the header to output the csv format document, you can simply export the excel file in mysql. let's take a look at the example below.
The core code is here. the code is as follows:
header("Content-Type: application/vnd.ms-excel; charset=UTF-8"); 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/octet-stream"); header("Content-Type: application/download"); header("Content-Disposition: attachment;filename=".$title .".xls "); header("Content-Transfer-Encoding: binary ");
The following code is used to export the database to excel in php and the test is successful:
Address:
Reprinted at will, but please attach the article address :-)