spreadsheet = new Spreadsheet(); return $this; } public function addArray(array $data, string $start = 'A1') { $this->spreadsheet->getActiveSheet()->fromArray($data, null, $start); return $this; } public function send(string $filename) { header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header("Content-Disposition: attachment;filename='{$filename}'"); header('Cache-Control: max-age=0'); $writer = IOFactory::createWriter($this->spreadsheet, 'Xlsx'); $writer->save('php://output'); } }