PHP code example of gri3li / yii2-grid-file
1. Go to this page and download the library: Download gri3li/yii2-grid-file 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/ */
gri3li / yii2-grid-file example snippets
$export = new \gri3li\yii2gridfile\GridFile([
'dataProvider' => new \yii\data\ArrayDataProvider([
'allModels' => [
[
'name' => 'some name',
'date' => 1538571363,
],
[
'name' => 'name 2',
'date' => 1538571363,
],
],
]),
'columns' => [
'name',
'date:datetime',
],
'headerCellStyle' => [
'font' => ['bold' => true],
'fill' => [
'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
'startColor' => ['rgb' => 'CCCCCC'],
],
],
]);
$export->saveAs(\PhpOffice\PhpSpreadsheet\Writer\Xls::class, '/path/to/file.xls');
// $export->saveAs(\PhpOffice\PhpSpreadsheet\Writer\Xlsx::class, '/path/to/file.xlsx');
// $export->saveAs(\PhpOffice\PhpSpreadsheet\Writer\Ods::class, '/path/to/file.ods');
// $export->saveAs(\PhpOffice\PhpSpreadsheet\Writer\Html::class, '/path/to/file.html');
// $export->saveAs(\PhpOffice\PhpSpreadsheet\Writer\Csv::class, '/path/to/file.csv');
cd vendor/gri3li/yii2-grid-file/example/
php -S 127.0.0.1:8877