jakercz / nette-csv-response
Nette CSV response
1.0.0
2022-09-07 05:42 UTC
Requires
- nette/nette: >=2.0.0
This package is auto-updated.
Last update: 2024-11-07 10:11:51 UTC
README
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 \Nette\Application\Responses\CsvResponse($data, 'students.csv'); $this->sendResponse( $response ); } }
Individual settings example:
use Nette\Application\Responses\CsvResponse; $response ->setGlue( CsvResponse::SEMICOLON ) ->setOutputCharset( 'cp1250' ) ->setContentType( 'application/csv' ) ->setHeadingFormatter( 'strtoupper' ) ->setDataFormatter( 'trim' ) ;