https://github.com/ondics/yii1spreadsheet
Very easy Excel-Output for Yii1
https://github.com/ondics/yii1spreadsheet
excel spreadsheet yii-extension yii1
Last synced: 5 months ago
JSON representation
Very easy Excel-Output for Yii1
- Host: GitHub
- URL: https://github.com/ondics/yii1spreadsheet
- Owner: ondics
- Created: 2022-02-18T19:55:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-07T07:39:04.000Z (over 4 years ago)
- Last Synced: 2025-11-27T16:19:00.446Z (7 months ago)
- Topics: excel, spreadsheet, yii-extension, yii1
- Language: PHP
- Homepage:
- Size: 35.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Yii1 Spreadsheet Extensions
===========================
Provides very easy Excel-Output for Yii1
* works with `CArrayDataProvider`
* works with `CActiveDataProvider`
* provides flexible value formatting with PHP closures (see below)
This extension was built because the extension [phpoffice/phpexcel](https://packagist.org/packages/phpoffice/phpexcel) is marked as "archived/abandoned" and there was no Yii1 extension as successor to use the recommended [PhpSpreadsheet](https://github.com/PHPOffice/PhpSpreadsheet) library.
Tested with Yii1 version 1.1.25
## Installation
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist ondics/yii1spreadsheet
```
or add
```json
"ondics/spreadsheet": "*"
```
to the `require` section of your composer.json.
## Usage
$dataProvider = new CArrayDataProvider([
[
'name' => 'some name',
'price' => '9879',
],
[
'name' => 'name 2',
'price' => '79',
],
]);
$exporter = new Spreadsheet();
$exporter->dataProvider = $dataProvider;
$exporter->columns = [
'name',
[
'attribute' => 'price',
'header' => 'Price with VAT',
'value' => function($model,$key,$index,$x) {
return $model->price * 1.19;
},
'visible' => ($model->price > 20),
];
$exporter->send('myexcelfile.xlsx');
## Application Notes
This yii1 extension is a light backport of https://github.com/yii2tech/spreadsheet to Yii1. Some Yii2 base classes and features are required and thus provided
with this extensions and can be used during Excel export, e.g.
* In `colums` a closure can be used as value. This closue differs from the closure in Yii1. See the example above how to use this closure.
* The columns array is backported from Yii2 so see Yii2 docs for information
The `send` method cannot not use xsendfile to send a file directyle to the browser but has go over memory. This may affect very large Excel exports.
## Credits
Thanks to https://patreon.com/klimov_paul and yii2tech which provide https://github.com/yii2tech/spreadsheet
## Author
githubler@ondics.de
(C) 2022, Ondics GmbH