How MySQL is exported to Excel

Source: Internet
Author: User
Tags dname php and

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 &nbsp, 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 &nbsp 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.