private function createCsvResponse($fileName, $header, $records) {
    $csv = Writer::createFromString('');

    $csv->insertOne($header);
    $csv->insertAll($records);

    $response = new Response();
    $response->setContent($csv);

    $response->headers->set('Content-Type', 'text/csv');
    $response->headers->set('Content-Disposition', 'attachment; filename="' . $fileName . '"');

    return $response;
  }