I am recently using the following code to export my data in database as an excel file. But the output is showing as html page with correct data from database.
<?php
/* database connection here */
$file_type = "vnd.ms-excel";
$file_ending = "xls";
header("Content-Type: application/$file_type");
header("Content-Disposition: attachment; filename=$table.$file_ending");
header("Pragma: no-cache");
header("Expires: 0");
/* extract from database */
It pulls out the all data from database so I assume database function are correct but its just not saving as excel file. This code I used exactly the same in my previous project and working fine. Any idea how to solve this? plz help.