Reputation: 135
HI i am exporting my report in .xls format but when i try to save the file after some editing it alerts me that file type is Web Page. I want it to be in excel 97-2003 Workbook. Following is my code
if($exportType == "xls")
{
header("Content-type: application/x-msexcel");
header("Content-Disposition: attachment; filename=DD_Report.xls");
header("Content-Description: PHP/MYSQL Generated Data");
header('Content-Type: application/vnd.ms-excel');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
$strMainStart = "<table align='center' border='1' width='100%'>";
$strMainEnd = "</table>";
$strRowStart = "<tr>";
$strRowEnd = "</tr>";
$strColumnStart = "<td>";
$strColumnEnd = "</td>";
$strBoldStart = "<b>";
$strBoldClose = "</b>";
}
Upvotes: 0
Views: 1216
Reputation:
Your approach simply won't work: you're sending the mimetype for Excel, but sending HTML. It's not surprising that you get the message you get.
If you want to export in Excel format get a library like PHPExcel to do it.
Upvotes: 2