xsuchy09 / nette-csv-response
Nette CSV Response
0.4
2020-11-27 12:21 UTC
Requires
- php: >= 7.1
- ext-iconv: *
- ext-mbstring: *
- nette/application: ^2.4|^3.0
- nette/http: ^2.4|^3.0
- nette/utils: ^2.4|^3.1
This package is auto-updated.
Last update: 2024-10-27 21:55:00 UTC
README
Install:
composer require xsuchy09/nette-csv-response
Use:
class SomePresenter extends BasePresenter { public function actionDefault() { $data = [ [ 'name' => 'George', 'age' => 15, 'grade' => 2, ], [ 'name' => 'Jack', 'age' => 17, 'grade' => 4, ], [ 'name' => 'Mary', 'age' => 17, 'grade' => 1, ], ]; $response = new \XSuchy09\Application\Responses\CsvResponse($data, 'students.csv'); $this->sendResponse( $response ); } }
Individual settings example:
use \XSuchy09\Application\Responses\CsvResponse; // $response is instance of \XSuchy09\Application\Responses\CsvResponse $response ->setDelimiter(CsvResponse::SEMICOLON) ->setEnclosure('"') // this is default value so not require to call when set to " ->setEscapeChar('\\') // this is default value so not require to call when set to \ ->setOutputCharset('utf-8') // this is default value so not require to call when set to utf-8 ->setContentType('application/csv') ->setHeadingFormatter('mb_strtoupper') ->setDataFormatter('trim') ;