codeinc/symfony-phpspreadsheet-response

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

1.4 2023-12-08 11:22 UTC

This package is auto-updated.

Last update: 2024-10-08 13:07:44 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).