Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gri3li/yii2-grid-file
Yii2 extension that allows exporting data from providers
https://github.com/gri3li/yii2-grid-file
yii2-extension
Last synced: 3 months ago
JSON representation
Yii2 extension that allows exporting data from providers
- Host: GitHub
- URL: https://github.com/gri3li/yii2-grid-file
- Owner: gri3li
- License: bsd-3-clause
- Created: 2018-10-03T07:40:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-29T17:19:37.000Z (3 months ago)
- Last Synced: 2024-09-29T23:02:28.676Z (3 months ago)
- Topics: yii2-extension
- Language: PHP
- Homepage:
- Size: 14.6 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Data Export extension for Yii2
==============================This Yii2 extension provides ability to export data form instances of `yii\data\DataProviderInterface` to format supported by PhpSpreadsheet
Installation
------------Install the package via Composer:
```bash
composer require gri3li/yii2-grid-file
```Usage
-----```php
$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');
```More info about phpspreadsheet style [https://phpspreadsheet.readthedocs.io/en/latest/topics/recipes/#styles](https://phpspreadsheet.readthedocs.io/en/latest/topics/recipes/#styles)
Use case [https://github.com/gri3li/yii2-grid-file/tree/master/example](https://github.com/gri3li/yii2-grid-file/tree/master/example)
For run use case:
```
cd vendor/gri3li/yii2-grid-file/example/
php -S 127.0.0.1:8877
```open [http://127.0.0.1:8877](http://127.0.0.1:8877)