2017 © Pedro Peláez
 

library excelbundle

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

image

11ya/excelbundle

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

  • Thursday, June 20, 2013
  • by 11ya
  • Repository
  • 1 Watchers
  • 0 Stars
  • 138 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 116 Forks
  • 0 Open issues
  • 7 Versions
  • 4 % Grown

The README.md

Symfony2 Excel bundle

This bundle permits you to create an easily modifiable excel object. This is just a dependency injection that links, (*1)

3 Objects:, (*2)

  • The container in this bundle,, (*3)

  • The StreamWrapper in the n3bStreamresponse, (*4)

  • A Writer., (*5)

You could create your own writer extending n3b\Bundle\Util\HttpFoundation\StreamResponse\StreamWriterInterface or you could use the great PHPExcel library. With PHPExcel you can create xls, ods, pdf and more., (*6)

You have to know that csv is faster so I encourage you to use the built-in function for csv: http://it.php.net/manual-lookup.php?pattern=csv&lang=en&scope=quickref, (*7)

Migration

In order to follow the naming convention https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md all the liuggio namespaces are migrated to Liuggio., (*8)

This master is up-to-date to the symfony/symfony master actually on 2.1, (*9)

INSTALLATION with COMPOSER

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

    "require" : {
        "liuggio/excelbundle": ">=1.0.4",
    }

2 Register the bundle in app/AppKernel.php, (*11)

``` php $bundles = array( // ... new Liuggio\ExcelBundle\LiuggioExcelBundle(), );, (*12)


## INSTALLATION with deps file 1 Add to the following to your `deps` file, then run `php bin/vendors install` ``` yaml [PHPExcel] git=http://github.com/PHPOffice/PHPExcel.git target=/phpexcel version=origin/master [n3bStreamresponse] git=git://github.com/liuggio/Symfony2-StreamResponse.git target=n3b/src/n3b/Bundle/Util/HttpFoundation/StreamResponse [LiuggioExcelBundle] git=https://github.com/liuggio/ExcelBundle.git target=/bundles/Liuggio/ExcelBundle

2 Register the namespaces and prefixes in app/autoload.php:, (*13)

``` php $loader->registerNamespaces(array( // ... 'n3b\Bundle\Util\HttpFoundation\StreamResponse' => DIR.'/../vendor/n3b/src', 'Liuggio' => DIR.'/../vendor/bundles', )); $loader->registerPrefixes(array( // ... 'PHPExcel' => DIR.'/../vendor/phpexcel/Classes', ));, (*14)



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

AVAILABLE SERVICES

If you want to write, (*15)

``` php // create MS Excel5 $excelService = $this->get('xls.service_xls5'); // create pdf $this->get('xls.service_pdf'); // create MS Excel 2007 $this->get('xls.service_xls2007');, (*16)



If you want to read xls ``` php $excelObj = $this->get('xls.load_xls5')->load($filename);

USAGE

Create a controller in your bundle, (*17)

``` php, (*18)

namespace YOURNAME\YOURBUNDLE\Controller;, (*19)

use Symfony\Bundle\FrameworkBundle\Controller\Controller;, (*20)

class DefaultController extends Controller {, (*21)

public function indexAction($name)
{
    // ask the service for a Excel5
    $excelService = $this->get('xls.service_xls5');
    // or $this->get('xls.service_pdf');
    // or create your own is easy just modify services.yml


    // create the object see http://phpexcel.codeplex.com documentation
    $excelService->excelObj->getProperties()->setCreator("Maarten Balliauw")
                        ->setLastModifiedBy("Maarten Balliauw")
                        ->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");
    $excelService->excelObj->setActiveSheetIndex(0)
                ->setCellValue('A1', 'Hello')
                ->setCellValue('B2', 'world!');
    $excelService->excelObj->getActiveSheet()->setTitle('Simple');
    // Set active sheet index to the first sheet, so Excel opens this as the first sheet
    $excelService->excelObj->setActiveSheetIndex(0);

    //create the response
    $response = $excelService->getResponse();
    $response->headers->set('Content-Type', 'text/vnd.ms-excel; charset=utf-8');
    $response->headers->set('Content-Disposition', 'attachment;filename=stdream2.xls');

    // If you are using a https connection, you have to set those two headers for compatibility with IE <9
    $response->headers->set('Pragma', 'public');
    $response->headers->set('Cache-Control', 'maxage=1');
    return $response;        
}

}, (*22)


With the right writer (e.g. PHPExcel_Writer_Excel5) you could also write the output to a file: ``` php public function indexAction($name) { $excelService = $this->get('xls.service_xls5'); //...create php excel object $excelService->getStreamWriter()->write( $filename ); }

ADVANCED USE

If you need to, see and modify Liuggio\ExcelBundle\Resources\config\services.yml, (*23)

Contributors

@pivasyk, (*24)

@dirkbl, (*25)

@DerStoffel, (*26)

@artturi, (*27)

@isqad88, (*28)

@mazenovi, (*29)

@jochenhilgers, (*30)

@Squazic, (*31)

The Versions

20/06 2013

dev-master

9999999-dev 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

 

symfony2 excel xls bundle

20/06 2013

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

 

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

 

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

 

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

 

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

 

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

 

symfony2 excel xls bundle