Permalink
Browse files

added functional test

  • Loading branch information...
liuggio committed Dec 6, 2013
1 parent 81c5ee4 commit 24d2d5811745fcced938d93b1e7fad233e7bb493
View
@@ -1,2 +1,4 @@
+bin
vendor
-composer.lock
+composer.lock
+Tests/app/cache
View
@@ -0,0 +1,15 @@
+language: php
+
+php:
+ - "5.3"
+ - "5.4"
+
+before_install:
+ - wget http://cs.sensiolabs.org/get/php-cs-fixer.phar
+
+before_script:
+ - php php-cs-fixer.phar fix -v --dry-run .
+ - composer install --dev
+
+script:
+ - bin/phpunit
View
@@ -1,55 +1,26 @@
Symfony2 Excel bundle
============
+[![Build Status](https://travis-ci.org/liuggio/ExcelBundle.png)](https://travis-ci.org/liuggio/ExcelBundle)
[![Total Downloads](https://poser.pugx.org/liuggio/ExcelBundle/downloads.png)](https://packagist.org/packages/liuggio/ExcelBundle)
[![Latest Stable Version](https://poser.pugx.org/liuggio/ExcelBundle/v/stable.png)](https://packagist.org/packages/liuggio/ExcelBundle)
[![Latest Unstable Version](https://poser.pugx.org/liuggio/ExcelBundle/v/unstable.png)](https://packagist.org/packages/liuggio/ExcelBundle)
This bundle permits you to create an easily modifiable excel object.
-This is just a dependency injection that links
+You should know that csv is faster so I encourage you to use the built-in function for csv: http://php.net/manual-lookup.php?pattern=csv&lang=en&scope=quickref
-3 Objects:
+## Installation
-- The container in this bundle,
+**1** Add to composer.json to the `require` key
-- The StreamWrapper in the n3bStreamresponse
-
-- A Writer.
-
-
-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.
-
-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
-
-## 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.
-
-This master is up-to-date to the symfony/symfony master actually on 2.1
-
-
-## INSTALLATION with COMPOSER
-
-1 Add to composer.json to the `require` key
-
-```
+``` yml
"require" : {
- "liuggio/excelbundle": "@dev",
+ "liuggio/excelbundle": "2.0.x-dev",
}
```
-
-
-2 Register the bundle in ``app/AppKernel.php``
-
-``` php
- $bundles = array(
- // ...
- new Liuggio\ExcelBundle\LiuggioExcelBundle(),
- );
-```
-3 Enable the bundle in `app/AppKernel.php`
+**2** Register the bundle in ``app/AppKernel.php``
``` php
$bundles = array(
@@ -58,39 +29,29 @@ This master is up-to-date to the symfony/symfony master actually on 2.1
);
```
+## Services
-
-## AVAILABLE SERVICES
-
-If you want to write
-
-``` php
- // create MS Excel5
- $excelService = $this->get('xls.excel5');
- // create MS Excel 2007
- $this->get('xls.excel2007');
-
-```
-
-If you want to read xls
+The list of the services are listed in `/Resources/config/services.yml`.
``` php
- $excelService = $this->get('xls.excel5')->load($filename);
-
+// create MS Excel5
+$this->get('xls.excel5');
+// create MS Excel 2007
+$this->get('xls.excel2007');
+// read file
+$excelService = $this->get('xls.excel5')->load($filename);
```
-## USAGE
-
-Create a controller in your bundle
+## Example
+Create a controller in your bundle,
+there's a working example at `Tests/app/Controller/FakeController.php`.
``` php
-
namespace YOURNAME\YOURBUNDLE\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-
class DefaultController extends Controller
{
@@ -124,32 +85,24 @@ class DefaultController extends Controller
// If you are using a https connection, you have to set those two headers and use sendHeaders() for compatibility with IE <9
$response->headers->set('Pragma', 'public');
$response->headers->set('Cache-Control', 'maxage=1');
- $response->sendHeaders();
+
return $response;
}
}
-
```
-With the right writer (e.g. PHPExcel_Writer_Excel5) you could also write the output to a file:
+With the correct writer (e.g. PHPExcel_Writer_Excel5) you could also write the output to a file:
+
``` php
public function indexAction($name)
{
$excelService = $this->get('xls.excel5');
-
//...load and modify or create php excel object
-
- $excelService->getStreamWriter()->write( $filename );
+ $excelService->getStreamWriter()->write($filename);
}
```
-
-## ADVANCED USE
-
-If you need to, see and modify ``Liuggio\ExcelBundle\Resources\config\services.yml``
-
-
## Contributors
@pivasyk
@@ -164,6 +117,8 @@ If you need to, see and modify ``Liuggio\ExcelBundle\Resources\config\services.y
@mazenovi
+@gnat42
+
@jochenhilgers
@Squazic
View
@@ -1,185 +0,0 @@
-Symfony2 Excel bundle
-============
-
-This Bundle permits to create easly Excel object.
-This is just a dependency injection that links
-
-3 Objects:
-
-- The container in this bundle,
-
-- The StreamWrapper in the n3bStreamresponse
-
-- A Writer.
-
-
-You could create your own writer extending ``n3b\Bundle\Util\HttpFoundation\StreamResponse\StreamWriterInterface`` or you could use the Huge Xls library called PHPExcel.
-
-With PHPExcel you can create: xls, ods, pdf and more,
-
-you have to know that csv is pretty 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
-
-## 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.
-
-This master is up-to-date to the symfony/symfony master actually on 2.1
-
-
-## INSTALLATION with COMPOSER
-
-1 Add to composer.json to the `require` key
-
-```
-"liuggio/excelbundle": "dev-master",
-```
-
-and add the repositories:
-
-```
- "repositories": {
- "n3bStreamresponse": {
- "type": "package",
- "package": {
- "name": "n3bStreamresponse",
- "version": "master",
- "source": {
- "url": "git://github.com/liuggio/Symfony2-StreamResponse.git",
- "type": "git",
- "reference": "master"
- },
- "autoload": {
- "psr-0": { "n3b\\Bundle\\Util\\HttpFoundation\\StreamResponse": "n3b/src" }
- },
- "target-dir": "n3b/src/n3b/Bundle/Util/HttpFoundation/StreamResponse"
- }
- },
- "phpExcel": {
- "type": "package",
- "package": {
- "name": "phpExcel",
- "version": "master",
- "source": {
- "url": "git://github.com/liuggio/PHPExcel.git",
- "type": "git",
- "reference": "master"
- },
- "autoload": {
- "classmap": ["lib/"]
- }
- }
- }
- },
-
-```
-
-
-2 Register the bundle in ``app/AppKernel.php``
-
-``` php
- $bundles = array(
- // ...
- new Liuggio\ExcelBundle\LiuggioExcelBundle(),
- );
-```
-
-
-
-## AVAILABLE SERVICES
-
-If you want write
-
-``` php
- // create MS Excel5
- $xls_service = $this->get('xls.service_xls5');
- // create pdf
- $this->get('xls.service_pdf');
- // create MS Excel 2007
- $this->get('xls.service_xls2007');
-
-```
-
-
-If you want read xls
-
-``` php
- $exelObj = $this->get('xls.load_xls5')->load($filename);
-
-```
-
-
-
-
-## USAGE
-
-create a controller in your bundle
-
-
-``` php
-
-namespace YOURNAME\YOURBUNDLE\Controller;
-
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-
-
-class DefaultController extends Controller
-{
-
- public function indexAction($name)
- {
- // ask the service for a Excel5
- $xls_service = $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
- $xls_service->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");
- $xls_service->excelObj->setActiveSheetIndex(0)
- ->setCellValue('A1', 'Hello')
- ->setCellValue('B2', 'world!');
- $xls_service->excelObj->getActiveSheet()->setTitle('Simple');
- // Set active sheet index to the first sheet, so Excel opens this as the first sheet
- $xls_service->excelObj->setActiveSheetIndex(0);
-
- //create the response
- $response = $xls_service->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;
- }
-}
-
-```
-
-
-
-
-## ADVANCED USE
-
-if you need see and modify ``Liuggio\ExcelBundle\Resources\config\services.yml``
-
-
-## Contributors
-
-@pivasyk
-
-@dirkbl
-
-@DerStoffel
-
-@artturi
-
-@isqad88
-
-@mazenovi
View
@@ -68,14 +68,14 @@ public function getWriter($type = null)
public function getStreamWriter()
{
- $stream_writer = new $this->streamWriterClass("php://output");
- $stream_writer->setWriter($this->getWriter(),'save');
+ $streamWriter = new $this->streamWriterClass("php://output");
+ $streamWriter->setWriter($this->getWriter(),'save');
- return $stream_writer;
+ return $streamWriter;
}
/**
- * create the response with the file content
+ * Create the response with the file content.
*
* @return \Symfony\Component\HttpFoundation\Response
*/
Oops, something went wrong.

0 comments on commit 24d2d58

Please sign in to comment.