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;
  }
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;
  }
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 ; }
Generate CSV file.

@param $fileName
@param $header
@param $records
@return \Symfony\Component\HttpFoundation\Response
Generate CSV file .