header(\"Content-Type: application/vnd.ms-excel; charset=utf-8\");
header(\"Content-type: application/x-msexcel; charset=utf-8\");
header(\"Content-Disposition:
The problem is you typed the wrong file extension for excel file. you used .xsl instead of xls.
I know i came in late but it can help future readers of this post.
Try this
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header("Content-Disposition: attachment;filename=\"filename.xlsx\"");
header("Cache-Control: max-age=0");
Just try to add exit;
at the end of your PHP script.
You are giving multiple Content-Type
headers. application/vnd.ms-excel
is enough.
And there are couple of syntax error too. To statement termination with ;
on the echo statement and wrong filename extension.
header("Content-Type: application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=abc.xls"); //File name extension was wrong
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
echo "Some Text"; //no ending ; here