I have completed all the steps to generate the csv file in cakephp 3.2.Here
i have generated the vendor using composer.phar ,and in vendor i got
the csv plugin (friendsofcake) ,also i managed from controller to fetch data from database ,that one is also fine.
Actually my problem is that data showing in csv file not looking good.
i want space between header
,means in A=ID , B=invoice , C=net_totals , D=billing_date
and database data will be shown under respective column .
How to use deliminator ,eof and new line
Below i have attached some of my codes.
public function export() {
$this->response->download('export.csv');
$data = $this->Orders->find('all')->toArray();
$_serialize = 'data';
$_delimiter = ','; //tab
$_enclosure = '"';
$_newline = '\n';
$_eol = '~';
$_bom = false;
$_header = ['ID', 'Invoice', 'net_total','billing_date'];
$_extract = ['id', 'invoice_no', 'net_total','billing_date'];
$this->set(compact('data', '_serialize', '_header', '_extract', '_delimiter'));
$this->viewBuilder()->className('CsvView.Csv');
return;
}