Download the Excel File using Php
The given code is used to download the excel file using php or codeigniter. Here just normally given to the php code.
- First header describe to content type to extract the application text like which type of document.
- Second header is to give the content description to attach the file format for we need it.
- Next header is pragma to display the type to format.
- last one is display the file expires day to given in that attribute.
- finally we create the design and data for the files. that depends on the file format. in excel we must using tables because then we get sufficient content format.
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=excelfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo "<table><thead><th>S.No</th><th>Fname</th><th>Fname</th><th>Fname</th><th>Fname</th></thead><tbody>";
echo "</tbody></table>";
The second one is done to the word file to get the html page.
- First header describe to content type to extract the application text like which type of document.
- Second header is to give the content description to attach the file format for we need it. In that section we just change document type only.(For Example: filename = filename.docx or filename = filename.doc)
- Next header is pragma to display the type to format.
- last one is display the file expires day to given in that attribute.
- finally we create the design and data for the files. that depends on the file format. in excel we must using tables because then we get sufficient content format.
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=documentfile.doc");
header("Pragma: no-cache");
header("Expires: 0");
echo "<table><thead><th>S.No</th><th>Fname</th><th>Fname</th><th>Fname</th><th>Fname</th></thead><tbody>";
echo "</tbody></table>";
The given function to do the valuable data for printing the excel or word files. The given function to do the function on php programming. Here we do the same function on codeigniter as it is. The code igniter have the MVC so we do that on controller to function like redirect the data to where you save the above coding page. It is functioned to the data together on excel and word file. The structure of the data to do the function on programming to have the file save on file name different name on the coding.
It should be done to the function on the data is must to header. It have to perfect executable coding for the download file from the HTML page using PHP or Codeigniter.
It have to done the Process to data on this program it's not able to work. so given data is sufficient to work. Example download image given below to show the download the excel file.

