PHP code example of xsuchy09 / nette-csv-response

1. Go to this page and download the library: Download xsuchy09/nette-csv-response library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xsuchy09 / nette-csv-response example snippets


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 );
	}
}

use \XSuchy09\Application\Responses\CsvResponse;

// $response is instance of \XSuchy09\Application\Responses\CsvResponse
$response
	->setDelimiter(CsvResponse::SEMICOLON)
	->setEnclosure('"') // this is default value so not eadingFormatter('mb_strtoupper')
	->setDataFormatter('trim')
;