Problems with Excel file generation (.xlsx) with the PhpSpreadsheet library

0

I'm working on a project where I need to generate Excel files with bank information (reports).

I was able to do this with the PhpSpreadsheet library, however the file is saved on the server, and when I add the headers to force the file to be downloaded, it is corrupted. If shooting the headers it generates normally.

The headers I'm using:

header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="myfile.xlsx"');
header('Cache-Control: max-age=0');
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($sheet, 'Xlsx');
$writer->save('php://output');
    
asked by anonymous 24.10.2018 / 01:08

0 answers