Php uses the header to save the excel file. A simple file download example using the header () function. we briefly explained the excel operation tutorial. if you need it, please refer to it. The code is as follows: Copy the code header (Co) to use the header () function to download simple files for an instance. we briefly explained the excel operation tutorial. if you need it, please refer to it.
The code is as follows: |
|
Header ("Content-type: application/vnd. ms-excel "); Header ("Content-Disposition: attachment?filename=test_data.xls "); |
Instance
The code is as follows: |
|
$ Filename = "20090210.xls "; $ File = fopen (PUBLIC_EXPORT_DIR. $ filename, "r"); // open the file Header ("Content-type: application/force-download "); Header ("Accept-Ranges: bytes "); Header ("Content-Type: application/msexcel "); Header ("Accept-Length:". filesize (PUBLIC_EXPORT_DIR. $ filename )); Header ("Content-Disposition: attachment; filename =". $ filename ); Echo fread ($ file, filesize (PUBLIC_EXPORT_DIR. $ filename )); Fclose ($ file ); |
The extract () function is used to download simple files for an instance. we have briefly explained the excel operation tutorial. if you need it, you can refer to it. The code is as follows: header (Co...