Revision #228 has been created by rackycz on Aug 21, 2020, 6:46:25 PM with the memo:
Export to CSV
« previous (#227) next (#229) »
Changes
Title
unchanged
Yii v2 snippet guide
Category
unchanged
Tutorials
Yii version
unchanged
2.0
Tags
unchanged
tutorial,beginner,yii2
Content
changed
[...]
// Double quotes must be used around \n !
$csv = implode("\n", $rows);
$currentDate = date('Y-m-d_H-i-s');
return \Yii::$app->response->sendContentAsFile($csv, 'invoiceusers_' . $currentDate . '.csv', [
'mimeType' => 'application/csv',
'inline' => false[...]
// These 2 rows already existed
$searchModel = new InvoiceUserSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams)
if ($exportToCsv) {
$this->exportDataProviderToCsv($dataProvider);
return;[...]