MySQL to export to Excel file is very simple, execute a command like this:
select * from a table into outfile ' d:/file name. xls '; the above command you perform on the server, on the server D: disk, if the client command line execution, on the client d : Disk, If the client is executed by POST, then the server D: disk. The prerequisite for success is that you have login permissions  , you have SELECT permission, and you have file permissions, and if you do not have file permissions, you will not be able to execute Select ....into outfile and load Data infile .... and other operations. As for adding a button, click on the prompt to save the Excel file, I think you may refer to the page? If the   on the Web page, the operation of MySQL is generally blocked in the back, usually through the server-side scripting language (php,jsp,asp, etc.) to operation of MySQL, the following respectively, PHP and JavaScript as an example, the database query results are saved as xls method (two kinds of method I have practiced, is feasible): 1.php method: Call the header () function, the parameters are as follows: Header ("Content-type:application/msexcel"); header ("Content-disposition:filename=file001.xls"); these two functions before performing a database query operation in a PHP file. Generally, after the database query operation is finished, the query results can be presented to the client through functions such as echo (), printf (), such as to add the above two lines before the database operation, the client will no longer display the result, but a download and save as XLS dialog box, path and file name can be freely selected. Button <input Type=button ...> or link <a href=...> you can put it on page 1th, point to Page 2nd, page 1th is used to display the results to the client, 2nd page (php file) on the above two lines, and then Write the code on the connection database and perform the same query operation as on page 1th. So you click on the 1th page of this link will jump out of a downloaded and saved as XLS dialog box, the content is you see on the 1th page of the query results, saved in the format of XLS, After saving you can open it with Excel to operate. php is a server-side script, using the above method in fact the same data results from the service side to the client two times, the first time to display , the second time to package into XLS file for download. The 2.javascript method: first defines a JS function in the
How MySQL is exported to Excel