2017 © Pedro Peláez
 

symfony-bundle excelbundle

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

image

mobiledev-pro/excelbundle

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  • Wednesday, May 23, 2018
  • by MobileD-pro
  • Repository
  • 2 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 117 Forks
  • 0 Open issues
  • 15 Versions
  • 0 % Grown

The README.md

Symfony2 Excel bundle

This bundle permits you to create, modify and read excel objects., (*1)

Build Status Total Downloads Latest Stable Version Latest Unstable Version, (*2)

License

License, (*3)

Version 2

This is the shiny new version. There is a big BC with the 1.* version, but unit tests, functional tests, and the new factory is very simple to use., (*4)

Version 1.*

If you have installed an old version, and you are happy to use it, you could find documentation and files in the tag v1.0.6, browse the code., (*5)

Things to know:

CSV is faster so if you have to create simple xls file, I encourage you to use the built-in function for csv: http://php.net/manual-lookup.php?pattern=csv&lang=en&scope=quickref, (*6)

Installation

1 Add to composer.json to the require key, (*7)

``` shell $composer require liuggio/excelbundle, (*8)


**2** Register the bundle in ``app/AppKernel.php`` ``` php $bundles = array( // ... new Liuggio\ExcelBundle\LiuggioExcelBundle(), );

TL;DR

  • Create an empty object:

``` php $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject();, (*9)


- Create an object from a file: ``` php $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject('file.xls');
  • Create a Excel5 and write to a file given the object:
$writer = $this->get('phpexcel')->createWriter($phpExcelObject, 'Excel5');
$writer->save('file.xls');
  • Create a Excel5 and create a StreamedResponse:
$writer = $this->get('phpexcel')->createWriter($phpExcelObject, 'Excel5');
$response = $this->get('phpexcel')->createStreamedResponse($writer);
  • Create a Excel file with an image:
$writer = $this->get('phpexcel')->createPHPExcelObject();
$writer->setActiveSheetIndex(0);
$activesheet = $writer->getActiveSheet();

$drawingobject = $this->get('phpexcel')->createPHPExcelWorksheetDrawing();
$drawingobject->setName('Image name');
$drawingobject->setDescription('Image description');
$drawingobject->setPath('/path/to/image');
$drawingobject->setHeight(60);
$drawingobject->setOffsetY(20);
$drawingobject->setCoordinates('A1');
$drawingobject->setWorksheet($activesheet)

Not Only 'Excel5'

The list of the types are:, (*10)

  1. 'Excel5'
  2. 'Excel2007'
  3. 'Excel2003XML'
  4. 'OOCalc'
  5. 'SYLK'
  6. 'Gnumeric'
  7. 'HTML'
  8. 'CSV'

Example

Fake Controller

The best place to start is the fake Controller at Tests/app/Controller/FakeController.php, that is a working example., (*11)

More example

You could find a lot of examples in the official PHPExcel repository https://github.com/PHPOffice/PHPExcel/tree/develop/Examples, (*12)

For lazy devs

``` php namespace YOURNAME\YOURBUNDLE\Controller;, (*13)

use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\ResponseHeaderBag;, (*14)

class DefaultController extends Controller {, (*15)

public function indexAction($name)
{
    // ask the service for a Excel5
   $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject();

   $phpExcelObject->getProperties()->setCreator("liuggio")
       ->setLastModifiedBy("Giulio De Donato")
       ->setTitle("Office 2005 XLSX Test Document")
       ->setSubject("Office 2005 XLSX Test Document")
       ->setDescription("Test document for Office 2005 XLSX, generated using PHP classes.")
       ->setKeywords("office 2005 openxml php")
       ->setCategory("Test result file");
   $phpExcelObject->setActiveSheetIndex(0)
       ->setCellValue('A1', 'Hello')
       ->setCellValue('B2', 'world!');
   $phpExcelObject->getActiveSheet()->setTitle('Simple');
   // Set active sheet index to the first sheet, so Excel opens this as the first sheet
   $phpExcelObject->setActiveSheetIndex(0);

    // create the writer
    $writer = $this->get('phpexcel')->createWriter($phpExcelObject, 'Excel5');
    // create the response
    $response = $this->get('phpexcel')->createStreamedResponse($writer);
    // adding headers
    $dispositionHeader = $response->headers->makeDisposition(
        ResponseHeaderBag::DISPOSITION_ATTACHMENT,
        'stream-file.xls'
    );
    $response->headers->set('Content-Type', 'text/vnd.ms-excel; charset=utf-8');
    $response->headers->set('Pragma', 'public');
    $response->headers->set('Cache-Control', 'maxage=1');
    $response->headers->set('Content-Disposition', $dispositionHeader);

    return $response;        
}

} ```, (*16)

Contributors

the list of contributors, (*17)

Contribute

  1. fork the project
  2. clone the repo
  3. get the coding standard fixer: wget http://cs.sensiolabs.org/get/php-cs-fixer.phar
  4. before the PullRequest you should run the coding standard fixer with php php-cs-fixer.phar fix -v .

The Versions

23/05 2018
20/06 2016

v2.1.0

2.1.0.0 http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Giulio De Donato

symfony2 excel xls bundle

20/04 2016

v2.0.5

2.0.5.0 http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Giulio De Donato

symfony2 excel xls bundle

22/12 2015

v2.0.4

2.0.4.0 http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Giulio De Donato

symfony2 excel xls bundle

15/05 2015

v2.0.2

2.0.2.0 http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Giulio De Donato

symfony2 excel xls bundle

11/06 2014

v2.0.1

2.0.1.0 http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Giulio De Donato

symfony2 excel xls bundle

29/12 2013

v2.0.0

2.0.0.0 http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Giulio De Donato

symfony2 excel xls bundle

06/12 2013

v2.0.0-RC1

2.0.0.0-RC1 http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Giulio De Donato

symfony2 excel xls bundle

31/10 2013

v1.0.6

1.0.6.0 http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  Sources   Download

MIT

The Requires

 

by Giulio De Donato

symfony2 excel xls bundle

10/09 2013

v1.0.5

1.0.5.0 http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  Sources   Download

MIT

The Requires

 

by Giulio De Donato

symfony2 excel xls bundle

25/04 2013

dev-excel-forks

dev-excel-forks http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  Sources   Download

MIT

The Requires

 

by Giulio De Donato

symfony2 excel xls bundle

21/02 2013

v1.0.4

1.0.4.0 http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  Sources   Download

MIT

The Requires

 

by Giulio De Donato

symfony2 excel xls bundle

03/12 2012

v1.0.2

1.0.2.0 http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  Sources   Download

MIT

The Requires

 

by Giulio De Donato

symfony2 excel xls bundle

28/09 2012

v1.0.0

1.0.0.0 http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  Sources   Download

MIT

The Requires

 

by Giulio De Donato

symfony2 excel xls bundle

28/09 2012

v0.0.8

0.0.8.0 http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library

  Sources   Download

MIT

The Requires

 

by Giulio De Donato

symfony2 excel xls bundle