2017 © Pedro Peláez
 

symfony-bundle wordbundle

This is a Symfony2 Bundle helps you to read and write Word files (including odt, rtf), thanks to the PHPWord library

image

tecno/wordbundle

This is a Symfony2 Bundle helps you to read and write Word files (including odt, rtf), thanks to the PHPWord library

  • Friday, May 30, 2014
  • by desarrollotecno
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Symfony2 Excel bundle

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

This bundle permits you to create an easily modifiable excel object., (*2)

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., (*3)

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., (*4)

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, (*5)

Installation

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

``` yml "require" : { "liuggio/excelbundle": "~2.0", }, (*7)


**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();, (*8)


- 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 = $writer->createStreamedResponse($writer);

Not Only 'Excel5'

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

  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., (*10)

More example

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

For lazy devs

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

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

class DefaultController extends Controller {, (*14)

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
    $response->headers->set('Content-Type', 'text/vnd.ms-excel; charset=utf-8');
    $response->headers->set('Content-Disposition', 'attachment;filename=stream-file.xls');
    $response->headers->set('Pragma', 'public');
    $response->headers->set('Cache-Control', 'maxage=1');

    return $response;        
}

} ```, (*15)

Contributors

the list of contributors, (*16)

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

30/05 2014

dev-master

9999999-dev http://www.welcometothebundle.com

This is a Symfony2 Bundle helps you to read and write Word files (including odt, rtf), thanks to the PHPWord library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tecno-Soluciones

symfony2 bundle word doc