php导出到excel在网站的IE中不起作用

I am trying to export data from database to an excel sheet, using php and mysql. It works fine in my localhost in IE and all browsers, but fails in the real website in IE (a hostmonster site). It says the file could not be downloaded.

This is my sample code that generates dynamic data and offers download:

<?php
while($node_stmt = mysql_fetch_array($result))
    {
    $contents.="\t\t".$node_stmt['uniqueid']."\t";          
    $contents.=$node_stmt['title'].' '.
    ucfirst($node_stmt['firstname']).' '.
    ucfirst($node_stmt['lastname'])."\t";

        $contents.=$node_stmt1['topic']."\t";
        $contents.=$abst."\t";
        $contents.=$node_stmt['email']."\t";
        $contents.=$node_stmt['phoneno']."\t";
        $contents.=$pay."\t";
        $contents.=$node_stmt['state_id']."\t";
        $contents.=$node_stmt['country_id']."
";
    }

.....

header('Content-Transfer-Encoding: none');
header('Content-Type: application/vnd.ms-excel;'); // This should work for IE & Opera
header("Content-type: application/x-msexcel"); // This should work for the rest
header('Content-Disposition: attachment; filename="'.basename($filename).'"');

echo $contents; 
?>

Do i need to change any settings with the host or IE?

$filename ='excelreport.xls';
$contents = "testdata1 \t testdata2 \t testdata3 \t 
";
header('Content-type: application/ms-excel');
header('Content-Disposition: attachment; filename='.$filename);
echo $contents;

You file is not application/vnd.ms-excel nor is it application/x-msexcel it's text/tab-separated-values http://www.iana.org/assignments/media-types/text/tab-separated-values

However that mime type may not be well known so use text/csv which will work OK for tsv as well.

Also when you do Content-Disposition: attachment it means to save the file. If you want browsers to open it in excel you need inline. (Some browsers let the user override this, some don't.)