duanjia9577 2015-09-21 09:58
浏览 89

PHPExcel不是很好

Hello I'm trying to generate and download excel file via Ajax, but unfortunately I'm getting this error not well-formed and nothing more specific.. I've checked all the variables etc and I'm sure that there aren't missing any required values.. So basically this is the code which calls PHPExcel script..

$("#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();

});

And this is the ending header code for generating excel document.. (I will not show all the previous code as I know there is everything ok and with no errors, already checked and working in different pages) The only part which gives errors here is the header information..

// 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;

P.S. This page isn't giving any output.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)