1 回答

TA贡献1829条经验 获得超9个赞
您可以清除输出缓冲区以停止任何已经echod. 然后exit是您交付内容后的脚本。
//protect against infinite looping, in case of an error with ob_end_clean()
$successfulClean = TRUE;
//empty the output buffer
while (ob_get_level()!==0
&&$successfulClean===TRUE){
$successfulClean = ob_end_clean();
}
// your code
$writer = IOFactory::createWriter($spreadsheet, "Xlsx"); //Xls is also possible
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="VIEW-tilbud.xls"');
header('Cache-Control: max-age=0');
$writer->save("php://output");
//------
//end the request, to stop your CMS from mucking things up. Content Mucking System lol
exit;
- 1 回答
- 0 关注
- 325 浏览
添加回答
举报