ticketpark/excel-bundle

This bundle assists in creating Excel files with HtmlPhpExcel

Installs: 12 208

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 4

Forks: 0

Open Issues: 0

Type:symfony-bundle

0.2 2016-06-23 12:26 UTC

This package is not auto-updated.

Last update: 2023-11-22 08:14:33 UTC


README

This Symfony2 bundle implements HtmlPhpExcel to create excel files from html tables.

Functionalities

  • ExcelCreator (Service)
    • Create excel files from html templates

Installation

Add TicketparkExcelBundle in your composer.json:

{
    "require": {
        "ticketpark/excel-bundle": "dev-master"
    }
}

Now tell composer to download the bundle by running the command:

$ php composer.phar update ticketpark/excel-bundle

Enable the bundles in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Ticketpark\ExcelBundle\TicketparkExcelBundle(),
        new Ticketpark\FileBundle\TicketparkFileBundle(),
    );
}

Usage of ExcelCreator

Use the excel creator service in a controller to create a excel:

$file = $this->get('ticketpark.excel.creator')
    ->setIdentifier('someIdentifier') // the identifier is used for caching purposes
    ->setContent('<table><tr><td>foo</td></tr></table>')
    ->create();
    
// Output the file (example, this is not connected to the bundle)
$headers = array(
 'Content-Type' => 'application/vnd.ms-excel',
 'Content-Disposition' => 'attachment; filename="filename.xlsx"'
);

return new Symfony\Component\HttpFoundation\Response(file_get_contents($file), 200, $headers);

License

This bundle is under the MIT license. See the complete license in the bundle:

Resources/meta/LICENSE