Skip to content

codeinchq/symfony-phpspreadsheet-response

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Symfony PhpSpreadsheet HTTP response

A simple Symfony HTTP response for PhpSpreadsheet written in PHP 8 intended to the used with Symfony's HTTPFoundation component.

Usage

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

Installation

This library is available through Packagist and can be installed using Composer:

composer require codeinc/symfony-phpspreadsheet-response

License

This library is published under the MIT license (see the LICENSE file).