id = $id; } public function getId(): string { return $this->id; } public function setTitle(string $title): void { $this->title = $title; } public function setLocale(?string $locale): void { $this->locale = $locale; } public function getTitle(): string { return $this->title; } /** * @param ExportableItem[] $exportItems */ public function render(array $exportItems, TimesheetQuery $query): Response { return $this->getFileResponse( $this->renderFile($exportItems, $query), (new ExportFilename($query))->getFilename() . '.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ); } /** * @param ExportableItem[] $exportItems */ private function renderFile(array $exportItems, TimesheetQuery $query): \SplFileInfo { $filename = @tempnam(sys_get_temp_dir(), 'kimai-export-xlsx'); if (false === $filename) { throw new \Exception('Could not open temporary file'); } $spreadsheet = new SpoutSpreadsheet(new Writer(), $this->translator, $this->locale); $spreadsheet->open($filename); $this->spreadsheetRenderer->writeSpreadsheet($spreadsheet, $exportItems, $query); return new \SplFileInfo($filename); } }