我正在使用Phpspreadsheet生成 Excel 文件。
我想直接将文件输出为下载。所以我使用了以下代码:
$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");
但这包括页面的所有内容,所以我的 Excel 文件被奇怪的字符损坏。我无法摆脱从 CMS 系统生成的页面上的额外内容,因此我将无法仅拥有导出 Excel 文件所需的代码。
如何使代码仅导出页面的特定部分?
PIPIONE