use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');
$writer = new Xlsx($spreadsheet);
$writer->save("demo.xlsx");
не предлагается сохранить файл (как должно быть)
header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="my_file.xlsx"');
$writer->save('php://output');