Download PhpSpreadsheet file without save it before : <p>I'm using <a href="https://github.com/PHPOffice/PhpSpreadsheet" rel="noreferrer">PhpSpreadsheet</a> to generate an Excel file in Symfony 4. My code is:</p>

<pre><code>$spreadsheet = $this-&gt;generateExcel($content);

$writer = new Xlsx($spreadsheet);
$filename = "myFile.xlsx";
$writer-&gt;save($filename); // LINE I WANT TO AVOID
$response = new BinaryFileResponse($filename);
$response-&gt;headers-&gt;set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
$response-&gt;setContentDisposition(
    ResponseHeaderBag::DISPOSITION_ATTACHMENT,
    $filename
);
</code></pre>

<p>But I don't want to save the file and then read it to return to the user. I would like to download Excel content directly. Is there a way to do It?</p>

<p>I've searched how to generate a stream of the content (as <a href="https://stackoverflow.com/a/39247345">this answer</a> says) but I hadn't success.</p>

<p>Thanks in advance and sorry about my English</p>
