PHP - 将数据导出到excel

I have some data that I need to export to excel. Right now it exports to some other type of file, that I am able to open and read with notepad, but not excel.

Here is the code:

<?php
    header("Content-Disposition: attachment; filename=\"ISBN\"");
    header("Content-Type: application/vnd.xls");
        // filename for download    
function output($data){ 

    //print_r($data);
    $str = preg_replace("/\t/", "\\t", $data);
    $str = preg_replace("/?
/", "\
", $str);
    if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"';


    $filename = "nonprofitdata" . date_default_timezone_set('Ymd') . ".xls";

        $flag = false;
        foreach($data as $row) {
            if(!$flag) {
                // display field/column names as first row
                echo implode("\t", array_keys($row)) . "
";
                $flag = true;
            }
        array_walk($row, 'cleanData');
        echo implode("\t", array_values($row)) . "
";
        }
        exit;
}
?>

How can I update this so that it will export to a file type that Excel can read?