PHP code example of codeinc / symfony-phpspreadsheet-response

1. Go to this page and download the library: Download codeinc/symfony-phpspreadsheet-response library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codeinc / symfony-phpspreadsheet-response example snippets



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");
    }
}