您好我正在尝试通过Ajax生成并下载excel文件,但遗憾的是我收到此错误not well-formed
并没有更具体的内容..我已经检查了所有变量等,我确信没有遗漏任何所需的值..
所以基本上这是调用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();
});
这是生成excel文档的结束标题代码..(我不会显示所有以前的代码,因为我知道一切正常,没有错误,已经检查并在不同的页面中工作)唯一的部分给出这里的错误是标题信息..
// 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。此页面未提供任何输出。