Php directly generates an excel file on the webpage to provide the download method
When you run the above code in the php environment, you can see the browser asking you whether to download the excel document, click save, and an excel file is added to the hard disk, you can see the final result when using excel. In fact, when doing real applications, you can extract the data from the database, and then add \ t after each column of data ends, after each row ends, add the \ n method for echo and use header ("Content-type: application/vnd. ms-excel ") indicates that the excel file is output, and the file name output is text.xls using header (" Content-Disposition: filename=test.xls. In this case, OK.
- Header ("Content-type: application/vnd. ms-excel ");
- Header ("Content-Disposition: filename=test.xls ");
- Echo "test1 \ t ";
- Echo "test2 \ t \ n ";
- Echo "test1 \ t ";
- Echo "test2 \ t \ n ";
- Echo "test1 \ t ";
- Echo "test2 \ t \ n ";
- Echo "test1 \ t ";
- Echo "test2 \ t \ n ";
- Echo "test1 \ t ";
- Echo "test2 \ t \ n ";
- Echo "test1 \ t ";
- Echo "test2 \ t \ n ";
- ?>
|
Php, excel