codeinc/symfony-phpspreadsheet-response

A simple Symfony HTTP response for PhpSpreadsheet written in PHP 8.

1.5 2024-11-06 12:19 UTC

This package is auto-updated.

Last update: 2024-12-06 12:27:51 UTC


README

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).