Skip to content

Commit

Permalink
Merge pull request #8 from pivasyk/master
Browse files Browse the repository at this point in the history
added createReader as xls.load_xls5 service
  • Loading branch information
liuggio committed May 2, 2012
2 parents c6178af + 04b699b commit be14b48
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ class DefaultController extends Controller

```

If you want read xls if your controller:

``` php
$exelObj = $this->get('xls.load_xls5')->load($filename);

```


## ADVANCED USE

Expand Down
11 changes: 11 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ services:
factory_class: %xls.factory.class%
factory_method: createWriter
arguments: [@xls.phpexcel, "Excel5"]

#reader for xls5
xls.load_xls5:
class: %xls.factory5.method%
factory_class: %xls.factory.class%
factory_method: createReader
arguments: ["Excel5"]



#setter injection
xls.stream_writer_output_xls5:
class: %xls.stream_writer.class%
Expand All @@ -29,6 +39,7 @@ services:
xls.service_xls5:
class: %xls.service.class%
arguments: [@xls.phpexcel, @xls.stream_writer_output_xls5, %xls.stream_response.class%]


# if you need to create another PHP object
#factory for another format
Expand Down
17 changes: 7 additions & 10 deletions Service/ExcelContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@ class ExcelContainer
* @var
*/
public $excelObj;

/**
* @var
*/
protected $stream_writer;

/**
* @var
*/
protected $response_service;


/**
* @param $excelObj
* @param $factory_writer
* @param string $factory_write_method
* @param $stream_writer
* @param $response_service
*/

public function __construct($excelObj, $stream_writer, $response_service)
{
$this->setExcelObj($excelObj);
$this->setStreamWriter($stream_writer);
$this->setResponseService($response_service);

}

/*
* create the response with the file content
*
* @return \Symfony\Component\HttpFoundation\Response
*/
* create the response with the file content
*
* @return \Symfony\Component\HttpFoundation\Response
*/

public function getResponse()
{
$responsiveClass = $this->getResponseService();
Expand Down Expand Up @@ -71,8 +71,6 @@ public function getExcelObj()
return $this->excelObj;
}



/**
* @param $response_service
*/
Expand Down Expand Up @@ -105,5 +103,4 @@ public function getStreamWriter()
return $this->stream_writer;
}


}

0 comments on commit be14b48

Please sign in to comment.