A simple Symfony HTTP response for PhpSpreadsheet written in PHP 8 intended to the used with Symfony's HTTPFoundation component.
<?php
use CodeInc\SpreadsheetResponse\SpreadsheetResponse;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use Symfony\Component\HttpFoundation\Response;
class MyController extends AbstractController {
#[Route("/a-spreadsheet", name: "download_a_spreadsheet")]
public function downloadASpreadsheet(): Response {
$spreadsheet = new Spreadsheet();
// building the spreadsheet...
return new SpreadsheetResponse($spreadsheet, "A spreadsheet.xlsx");
}
}
This library is available through Packagist and can be installed using Composer:
composer require codeinc/symfony-phpspreadsheet-response
This library is published under the MIT license (see the LICENSE file).