$data */ public function process(array $configuration, \Generator $data): void { $data = $this->getFlattenedGenerator($configuration, $data); $header = []; // create header by first item if ($first = $data->current()) { foreach (array_keys($first) as $key) { $header[$key] = ['name' => $key]; } } $data->rewind(); // use generateExcelInternal bcs headers (filename, content type) are set implicitly by feeds route $this->excelGenerator->generateExcelInternal($header, $data); } }