PHPExcel格式不正确

PHPExcel格式不正确,php,ajax,excel,phpexcel,Php,Ajax,Excel,Phpexcel,您好,我正试图通过Ajax生成并下载excel文件,但不幸的是,我遇到了此错误格式不正确,并且没有更具体的内容。。我已经检查了所有变量等,我确信没有遗漏任何必需的值。。 基本上这就是调用PHPExcel脚本的代码 $("#myForm").submit(function(e) { var group_id = <?php echo $group_id; ?>; var month = <?php echo $month; ?>;

您好,我正试图通过Ajax生成并下载excel文件,但不幸的是,我遇到了此错误
格式不正确
,并且没有更具体的内容。。我已经检查了所有变量等,我确信没有遗漏任何必需的值。。 基本上这就是调用PHPExcel脚本的代码

$("#myForm").submit(function(e) {

    var group_id    = <?php echo $group_id; ?>;
    var month       = <?php echo $month; ?>;
    var year        = <?php echo $year; ?>;

    $.ajax({
        url: 'ajax/events_to_excel.php?id='+group_id+'&m='+month+'&y='+year,
        type: 'POST',
        data: $(this).serialize(),
        success: function(data, textStatus, jqXHR) {
            //console.log(data);
        },
        error: function(jqXHR, textStatus, errorThrown) {

        }

    }). done(function(data) {

    });

    e.preventDefault();

});

p.S.此页面未提供任何输出。

因此,如果响应成功,您的Ajax将如何处理作为响应流传输的文件?如果您使用Ajax,那么您需要提供自己的响应处理程序来处理流式二进制文件。。。浏览器不会像链接到events_to_excel.php那样为您执行此操作。请在注释中输入所有标题和编写器内容,然后调用页面,然后您会在屏幕上看到一些错误。因此,如果响应成功,您的Ajax将如何处理作为响应流的文件?如果您使用Ajax,那么您需要提供自己的响应处理程序来处理流式二进制文件。。。浏览器不会像链接到events_to_excel.php那样为您执行此操作。请在注释中显示所有标题和编写器内容,然后调用页面,然后您应该会在屏幕上看到一些错误。。
// Redirect output to a client’s web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');

// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
ob_end_clean();
$objWriter->save('php://output');
exit;